OpenCoverage

qgraphicsscene.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicsscene.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40/*!-
41 \class QGraphicsScene-
42 \brief The QGraphicsScene class provides a surface for managing a large-
43 number of 2D graphical items.-
44 \since 4.2-
45 \ingroup graphicsview-api-
46 \inmodule QtWidgets-
47-
48 The class serves as a container for QGraphicsItems. It is used together-
49 with QGraphicsView for visualizing graphical items, such as lines,-
50 rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is-
51 part of the \l{Graphics View Framework}.-
52-
53 QGraphicsScene also provides functionality that lets you efficiently-
54 determine both the location of items, and for determining what items are-
55 visible within an arbitrary area on the scene. With the QGraphicsView-
56 widget, you can either visualize the whole scene, or zoom in and view only-
57 parts of the scene.-
58-
59 Example:-
60-
61 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 0-
62-
63 Note that QGraphicsScene has no visual appearance of its own; it only-
64 manages the items. You need to create a QGraphicsView widget to visualize-
65 the scene.-
66-
67 To add items to a scene, you start off by constructing a QGraphicsScene-
68 object. Then, you have two options: either add your existing QGraphicsItem-
69 objects by calling addItem(), or you can call one of the convenience-
70 functions addEllipse(), addLine(), addPath(), addPixmap(), addPolygon(),-
71 addRect(), or addText(), which all return a pointer to the newly added item.-
72 The dimensions of the items added with these functions are relative to the-
73 item's coordinate system, and the items position is initialized to (0,-
74 0) in the scene.-
75-
76 You can then visualize the scene using QGraphicsView. When the scene-
77 changes, (e.g., when an item moves or is transformed) QGraphicsScene-
78 emits the changed() signal. To remove an item, call removeItem().-
79-
80 QGraphicsScene uses an indexing algorithm to manage the location of items-
81 efficiently. By default, a BSP (Binary Space Partitioning) tree is used; an-
82 algorithm suitable for large scenes where most items remain static (i.e.,-
83 do not move around). You can choose to disable this index by calling-
84 setItemIndexMethod(). For more information about the available indexing-
85 algorithms, see the itemIndexMethod property.-
86-
87 The scene's bounding rect is set by calling setSceneRect(). Items can be-
88 placed at any position on the scene, and the size of the scene is by-
89 default unlimited. The scene rect is used only for internal bookkeeping,-
90 maintaining the scene's item index. If the scene rect is unset,-
91 QGraphicsScene will use the bounding area of all items, as returned by-
92 itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a-
93 relatively time consuming function, as it operates by collecting-
94 positional information for every item on the scene. Because of this, you-
95 should always set the scene rect when operating on large scenes.-
96-
97 One of QGraphicsScene's greatest strengths is its ability to efficiently-
98 determine the location of items. Even with millions of items on the scene,-
99 the items() functions can determine the location of an item within a few-
100 milliseconds. There are several overloads to items(): one that finds items-
101 at a certain position, one that finds items inside or intersecting with a-
102 polygon or a rectangle, and more. The list of returned items is sorted by-
103 stacking order, with the topmost item being the first item in the list.-
104 For convenience, there is also an itemAt() function that returns the-
105 topmost item at a given position.-
106-
107 QGraphicsScene maintains selection information for the scene. To select-
108 items, call setSelectionArea(), and to clear the current selection, call-
109 clearSelection(). Call selectedItems() to get the list of all selected-
110 items.-
111-
112 \section1 Event Handling and Propagation-
113-
114 Another responsibility that QGraphicsScene has, is to propagate events-
115 from QGraphicsView. To send an event to a scene, you construct an event-
116 that inherits QEvent, and then send it using, for example,-
117 QApplication::sendEvent(). event() is responsible for dispatching-
118 the event to the individual items. Some common events are handled by-
119 convenience event handlers. For example, key press events are handled by-
120 keyPressEvent(), and mouse press events are handled by mousePressEvent().-
121-
122 Key events are delivered to the \e {focus item}. To set the focus item,-
123 you can either call setFocusItem(), passing an item that accepts focus, or-
124 the item itself can call QGraphicsItem::setFocus(). Call focusItem() to-
125 get the current focus item. For compatibility with widgets, the scene also-
126 maintains its own focus information. By default, the scene does not have-
127 focus, and all key events are discarded. If setFocus() is called, or if an-
128 item on the scene gains focus, the scene automatically gains focus. If the-
129 scene has focus, hasFocus() will return true, and key events will be-
130 forwarded to the focus item, if any. If the scene loses focus, (i.e.,-
131 someone calls clearFocus()) while an item has focus, the scene will-
132 maintain its item focus information, and once the scene regains focus, it-
133 will make sure the last focus item regains focus.-
134-
135 For mouse-over effects, QGraphicsScene dispatches \e {hover-
136 events}. If an item accepts hover events (see-
137 QGraphicsItem::acceptHoverEvents()), it will receive a \l-
138 {QEvent::}{GraphicsSceneHoverEnter} event when the mouse enters-
139 its area. As the mouse continues moving inside the item's area,-
140 QGraphicsScene will send it \l {QEvent::}{GraphicsSceneHoverMove}-
141 events. When the mouse leaves the item's area, the item will-
142 receive a \l {QEvent::}{GraphicsSceneHoverLeave} event.-
143-
144 All mouse events are delivered to the current \e {mouse grabber}-
145 item. An item becomes the scene's mouse grabber if it accepts-
146 mouse events (see QGraphicsItem::acceptedMouseButtons()) and it-
147 receives a mouse press. It stays the mouse grabber until it-
148 receives a mouse release when no other mouse buttons are-
149 pressed. You can call mouseGrabberItem() to determine what item is-
150 currently grabbing the mouse.-
151-
152 \sa QGraphicsItem, QGraphicsView-
153*/-
154-
155/*!-
156 \enum QGraphicsScene::SceneLayer-
157 \since 4.3-
158-
159 This enum describes the rendering layers in a QGraphicsScene. When-
160 QGraphicsScene draws the scene contents, it renders each of these layers-
161 separately, in order.-
162-
163 Each layer represents a flag that can be OR'ed together when calling-
164 functions such as invalidate() or QGraphicsView::invalidateScene().-
165-
166 \value ItemLayer The item layer. QGraphicsScene renders all items are in-
167 this layer by calling the virtual function drawItems(). The item layer is-
168 drawn after the background layer, but before the foreground layer.-
169-
170 \value BackgroundLayer The background layer. QGraphicsScene renders the-
171 scene's background in this layer by calling the virtual function-
172 drawBackground(). The background layer is drawn first of all layers.-
173-
174 \value ForegroundLayer The foreground layer. QGraphicsScene renders the-
175 scene's foreground in this layer by calling the virtual function-
176 drawForeground(). The foreground layer is drawn last of all layers.-
177-
178 \value AllLayers All layers; this value represents a combination of all-
179 three layers.-
180-
181 \sa invalidate(), QGraphicsView::invalidateScene()-
182*/-
183-
184/*!-
185 \enum QGraphicsScene::ItemIndexMethod-
186-
187 This enum describes the indexing algorithms QGraphicsScene provides for-
188 managing positional information about items on the scene.-
189-
190 \value BspTreeIndex A Binary Space Partitioning tree is applied. All-
191 QGraphicsScene's item location algorithms are of an order close to-
192 logarithmic complexity, by making use of binary search. Adding, moving and-
193 removing items is logarithmic. This approach is best for static scenes-
194 (i.e., scenes where most items do not move).-
195-
196 \value NoIndex No index is applied. Item location is of linear complexity,-
197 as all items on the scene are searched. Adding, moving and removing items,-
198 however, is done in constant time. This approach is ideal for dynamic-
199 scenes, where many items are added, moved or removed continuously.-
200-
201 \sa setItemIndexMethod(), bspTreeDepth-
202*/-
203-
204#include "qgraphicsscene.h"-
205-
206#ifndef QT_NO_GRAPHICSVIEW-
207-
208#include "qgraphicsitem.h"-
209#include "qgraphicsitem_p.h"-
210#include "qgraphicslayout.h"-
211#include "qgraphicsscene_p.h"-
212#include "qgraphicssceneevent.h"-
213#include "qgraphicsview.h"-
214#include "qgraphicsview_p.h"-
215#include "qgraphicswidget.h"-
216#include "qgraphicswidget_p.h"-
217#include "qgraphicssceneindex_p.h"-
218#include "qgraphicsscenebsptreeindex_p.h"-
219#include "qgraphicsscenelinearindex_p.h"-
220-
221#include <QtCore/qdebug.h>-
222#include <QtCore/qlist.h>-
223#include <QtCore/qmath.h>-
224#include <QtCore/qrect.h>-
225#include <QtCore/qset.h>-
226#include <QtCore/qstack.h>-
227#include <QtCore/qtimer.h>-
228#include <QtCore/qvarlengtharray.h>-
229#include <QtCore/QMetaMethod>-
230#include <QtWidgets/qapplication.h>-
231#include <QtWidgets/qdesktopwidget.h>-
232#include <QtGui/qevent.h>-
233#include <QtWidgets/qgraphicslayout.h>-
234#include <QtWidgets/qgraphicsproxywidget.h>-
235#include <QtWidgets/qgraphicswidget.h>-
236#include <QtGui/qmatrix.h>-
237#include <QtGui/qpaintengine.h>-
238#include <QtGui/qpainter.h>-
239#include <QtGui/qpixmapcache.h>-
240#include <QtGui/qpolygon.h>-
241#include <QtGui/qtouchdevice.h>-
242#include <QtWidgets/qstyleoption.h>-
243#include <QtWidgets/qtooltip.h>-
244#include <QtGui/qtransform.h>-
245#include <QtGui/qinputmethod.h>-
246#include <QtWidgets/qgraphicseffect.h>-
247#include <private/qapplication_p.h>-
248#include <private/qobject_p.h>-
249#include <private/qgraphicseffect_p.h>-
250#include <private/qgesturemanager_p.h>-
251#include <private/qpathclipper_p.h>-
252-
253// #define GESTURE_DEBUG-
254#ifndef GESTURE_DEBUG-
255# define DEBUG if (0) qDebug-
256#else-
257# define DEBUG qDebug-
258#endif-
259-
260QT_BEGIN_NAMESPACE-
261-
262bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);-
263-
264static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent)-
265{-
266 hover->setWidget(mouseEvent->widget());-
267 hover->setPos(mouseEvent->pos());-
268 hover->setScenePos(mouseEvent->scenePos());-
269 hover->setScreenPos(mouseEvent->screenPos());-
270 hover->setLastPos(mouseEvent->lastPos());-
271 hover->setLastScenePos(mouseEvent->lastScenePos());-
272 hover->setLastScreenPos(mouseEvent->lastScreenPos());-
273 hover->setModifiers(mouseEvent->modifiers());-
274 hover->setAccepted(mouseEvent->isAccepted());-
275}
never executed: end of block
0
276-
277/*!-
278 \internal-
279*/-
280QGraphicsScenePrivate::QGraphicsScenePrivate()-
281 : indexMethod(QGraphicsScene::BspTreeIndex),-
282 index(0),-
283 lastItemCount(0),-
284 hasSceneRect(false),-
285 dirtyGrowingItemsBoundingRect(true),-
286 updateAll(false),-
287 calledEmitUpdated(false),-
288 processDirtyItemsEmitted(false),-
289 needSortTopLevelItems(true),-
290 holesInTopLevelSiblingIndex(false),-
291 topLevelSequentialOrdering(true),-
292 scenePosDescendantsUpdatePending(false),-
293 stickyFocus(false),-
294 hasFocus(false),-
295 lastMouseGrabberItemHasImplicitMouseGrab(false),-
296 allItemsIgnoreHoverEvents(true),-
297 allItemsUseDefaultCursor(true),-
298 painterStateProtection(true),-
299 sortCacheEnabled(false),-
300 allItemsIgnoreTouchEvents(true),-
301 minimumRenderSize(0.0),-
302 selectionChanging(0),-
303 rectAdjust(2),-
304 focusItem(0),-
305 lastFocusItem(0),-
306 passiveFocusItem(0),-
307 tabFocusFirst(0),-
308 activePanel(0),-
309 lastActivePanel(0),-
310 activationRefCount(0),-
311 childExplicitActivation(0),-
312 lastMouseGrabberItem(0),-
313 dragDropItem(0),-
314 enterWidget(0),-
315 lastDropAction(Qt::IgnoreAction),-
316 style(0)-
317{-
318}
never executed: end of block
0
319-
320/*!-
321 \internal-
322*/-
323void QGraphicsScenePrivate::init()-
324{-
325 Q_Q(QGraphicsScene);-
326-
327 index = new QGraphicsSceneBspTreeIndex(q);-
328-
329 // Keep this index so we can check for connected slots later on.-
330 changedSignalIndex = signalIndex("changed(QList<QRectF>)");-
331 processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()");-
332 polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()");-
333-
334 qApp->d_func()->scene_list.append(q);-
335 q->update();-
336}
never executed: end of block
0
337-
338/*!-
339 \internal-
340*/-
341QGraphicsScenePrivate *QGraphicsScenePrivate::get(QGraphicsScene *q)-
342{-
343 return q->d_func();
never executed: return q->d_func();
0
344}-
345-
346void QGraphicsScenePrivate::_q_emitUpdated()-
347{-
348 Q_Q(QGraphicsScene);-
349 calledEmitUpdated = false;-
350-
351 if (dirtyGrowingItemsBoundingRect) {
dirtyGrowingItemsBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
352 if (!hasSceneRect) {
!hasSceneRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
353 const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;-
354 growingItemsBoundingRect |= q->itemsBoundingRect();-
355 if (oldGrowingItemsBoundingRect != growingItemsBoundingRect)
oldGrowingItem...msBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
356 emit q->sceneRectChanged(growingItemsBoundingRect);
never executed: q->sceneRectChanged(growingItemsBoundingRect);
0
357 }
never executed: end of block
0
358 dirtyGrowingItemsBoundingRect = false;-
359 }
never executed: end of block
0
360-
361 // Ensure all views are connected if anything is connected. This disables-
362 // the optimization that items send updates directly to the views, but it-
363 // needs to happen in order to keep compatibility with the behavior from-
364 // Qt 4.4 and backward.-
365 if (isSignalConnected(changedSignalIndex)) {
isSignalConnec...edSignalIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
366 for (int i = 0; i < views.size(); ++i) {
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
367 QGraphicsView *view = views.at(i);-
368 if (!view->d_func()->connectedToScene) {
!view->d_func(...nnectedToSceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
369 view->d_func()->connectedToScene = true;-
370 q->connect(q, SIGNAL(changed(QList<QRectF>)),-
371 views.at(i), SLOT(updateScene(QList<QRectF>)));-
372 }
never executed: end of block
0
373 }
never executed: end of block
0
374 } else {
never executed: end of block
0
375 if (views.isEmpty()) {
views.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
376 updateAll = false;-
377 return;
never executed: return;
0
378 }-
379 for (int i = 0; i < views.size(); ++i)
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
380 views.at(i)->d_func()->processPendingUpdates();
never executed: views.at(i)->d_func()->processPendingUpdates();
0
381 // It's important that we update all views before we dispatch, hence two for-loops.-
382 for (int i = 0; i < views.size(); ++i)
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
383 views.at(i)->d_func()->dispatchPendingUpdateRequests();
never executed: views.at(i)->d_func()->dispatchPendingUpdateRequests();
0
384 return;
never executed: return;
0
385 }-
386-
387 // Notify the changes to anybody interested.-
388 QList<QRectF> oldUpdatedRects;-
389 oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects;
updateAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
390 updateAll = false;-
391 updatedRects.clear();-
392 emit q->changed(oldUpdatedRects);-
393}
never executed: end of block
0
394-
395/*!-
396 \internal-
397-
398 ### This function is almost identical to QGraphicsItemPrivate::addChild().-
399*/-
400void QGraphicsScenePrivate::registerTopLevelItem(QGraphicsItem *item)-
401{-
402 ensureSequentialTopLevelSiblingIndexes();-
403 needSortTopLevelItems = true; // ### maybe false-
404 item->d_ptr->siblingIndex = topLevelItems.size();-
405 topLevelItems.append(item);-
406}
never executed: end of block
0
407-
408/*!-
409 \internal-
410-
411 ### This function is almost identical to QGraphicsItemPrivate::removeChild().-
412*/-
413void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item)-
414{-
415 if (!holesInTopLevelSiblingIndex)
!holesInTopLevelSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
416 holesInTopLevelSiblingIndex = item->d_ptr->siblingIndex != topLevelItems.size() - 1;
never executed: holesInTopLevelSiblingIndex = item->d_ptr->siblingIndex != topLevelItems.size() - 1;
0
417 if (topLevelSequentialOrdering && !holesInTopLevelSiblingIndex)
topLevelSequentialOrderingDescription
TRUEnever evaluated
FALSEnever evaluated
!holesInTopLevelSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
418 topLevelItems.removeAt(item->d_ptr->siblingIndex);
never executed: topLevelItems.removeAt(item->d_ptr->siblingIndex);
0
419 else-
420 topLevelItems.removeOne(item);
never executed: topLevelItems.removeOne(item);
0
421 // NB! Do not use topLevelItems.removeAt(item->d_ptr->siblingIndex) because-
422 // the item is not guaranteed to be at the index after the list is sorted-
423 // (see ensureSortedTopLevelItems()).-
424 item->d_ptr->siblingIndex = -1;-
425 if (topLevelSequentialOrdering)
topLevelSequentialOrderingDescription
TRUEnever evaluated
FALSEnever evaluated
0
426 topLevelSequentialOrdering = !holesInTopLevelSiblingIndex;
never executed: topLevelSequentialOrdering = !holesInTopLevelSiblingIndex;
0
427}
never executed: end of block
0
428-
429/*!-
430 \internal-
431*/-
432void QGraphicsScenePrivate::_q_polishItems()-
433{-
434 if (unpolishedItems.isEmpty())
unpolishedItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
435 return;
never executed: return;
0
436-
437 const QVariant booleanTrueVariant(true);-
438 QGraphicsItem *item = 0;-
439 QGraphicsItemPrivate *itemd = 0;-
440 const int oldUnpolishedCount = unpolishedItems.count();-
441-
442 for (int i = 0; i < oldUnpolishedCount; ++i) {
i < oldUnpolishedCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
443 item = unpolishedItems.at(i);-
444 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
445 continue;
never executed: continue;
0
446 itemd = item->d_ptr.data();-
447 itemd->pendingPolish = false;-
448 if (!itemd->explicitlyHidden) {
!itemd->explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
449 item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);-
450 item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);-
451 }
never executed: end of block
0
452 if (itemd->isWidget) {
itemd->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
453 QEvent event(QEvent::Polish);-
454 QApplication::sendEvent((QGraphicsWidget *)item, &event);-
455 }
never executed: end of block
0
456 }
never executed: end of block
0
457-
458 if (unpolishedItems.count() == oldUnpolishedCount) {
unpolishedItem...npolishedCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
459 // No new items were added to the vector.-
460 unpolishedItems.clear();-
461 } else {
never executed: end of block
0
462 // New items were appended; keep them and remove the old ones.-
463 unpolishedItems.remove(0, oldUnpolishedCount);-
464 unpolishedItems.squeeze();-
465 QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection);-
466 }
never executed: end of block
0
467}-
468-
469void QGraphicsScenePrivate::_q_processDirtyItems()-
470{-
471 processDirtyItemsEmitted = false;-
472-
473 if (updateAll) {
updateAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
474 Q_ASSERT(calledEmitUpdated);-
475 // No need for further processing (except resetting the dirty states).-
476 // The growingItemsBoundingRect is updated in _q_emitUpdated.-
477 for (int i = 0; i < topLevelItems.size(); ++i)
i < topLevelItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
478 resetDirtyItem(topLevelItems.at(i), /*recursive=*/true);
never executed: resetDirtyItem(topLevelItems.at(i), true);
0
479 return;
never executed: return;
0
480 }-
481-
482 const bool wasPendingSceneUpdate = calledEmitUpdated;-
483 const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;-
484-
485 // Process items recursively.-
486 for (int i = 0; i < topLevelItems.size(); ++i)
i < topLevelItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
487 processDirtyItemsRecursive(topLevelItems.at(i));
never executed: processDirtyItemsRecursive(topLevelItems.at(i));
0
488-
489 dirtyGrowingItemsBoundingRect = false;-
490 if (!hasSceneRect && oldGrowingItemsBoundingRect != growingItemsBoundingRect)
!hasSceneRectDescription
TRUEnever evaluated
FALSEnever evaluated
oldGrowingItem...msBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
491 emit q_func()->sceneRectChanged(growingItemsBoundingRect);
never executed: q_func()->sceneRectChanged(growingItemsBoundingRect);
0
492-
493 if (wasPendingSceneUpdate)
wasPendingSceneUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
494 return;
never executed: return;
0
495-
496 for (int i = 0; i < views.size(); ++i)
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
497 views.at(i)->d_func()->processPendingUpdates();
never executed: views.at(i)->d_func()->processPendingUpdates();
0
498-
499 if (calledEmitUpdated) {
calledEmitUpdatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
500 // We did a compatibility QGraphicsScene::update in processDirtyItemsRecursive-
501 // and we cannot wait for the control to reach the eventloop before the-
502 // changed signal is emitted, so we emit it now.-
503 _q_emitUpdated();-
504 }
never executed: end of block
0
505-
506 // Immediately dispatch all pending update requests on the views.-
507 for (int i = 0; i < views.size(); ++i)
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
508 views.at(i)->d_func()->dispatchPendingUpdateRequests();
never executed: views.at(i)->d_func()->dispatchPendingUpdateRequests();
0
509}
never executed: end of block
0
510-
511/*!-
512 \internal-
513*/-
514void QGraphicsScenePrivate::setScenePosItemEnabled(QGraphicsItem *item, bool enabled)-
515{-
516 QGraphicsItem *p = item->d_ptr->parent;-
517 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
518 p->d_ptr->scenePosDescendants = enabled;-
519 p = p->d_ptr->parent;-
520 }
never executed: end of block
0
521 if (!enabled && !scenePosDescendantsUpdatePending) {
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!scenePosDesce...sUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
522 scenePosDescendantsUpdatePending = true;-
523 QMetaObject::invokeMethod(q_func(), "_q_updateScenePosDescendants", Qt::QueuedConnection);-
524 }
never executed: end of block
0
525}
never executed: end of block
0
526-
527/*!-
528 \internal-
529*/-
530void QGraphicsScenePrivate::registerScenePosItem(QGraphicsItem *item)-
531{-
532 scenePosItems.insert(item);-
533 setScenePosItemEnabled(item, true);-
534}
never executed: end of block
0
535-
536/*!-
537 \internal-
538*/-
539void QGraphicsScenePrivate::unregisterScenePosItem(QGraphicsItem *item)-
540{-
541 scenePosItems.remove(item);-
542 setScenePosItemEnabled(item, false);-
543}
never executed: end of block
0
544-
545/*!-
546 \internal-
547*/-
548void QGraphicsScenePrivate::_q_updateScenePosDescendants()-
549{-
550 foreach (QGraphicsItem *item, scenePosItems) {-
551 QGraphicsItem *p = item->d_ptr->parent;-
552 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
553 p->d_ptr->scenePosDescendants = 1;-
554 p = p->d_ptr->parent;-
555 }
never executed: end of block
0
556 }
never executed: end of block
0
557 scenePosDescendantsUpdatePending = false;-
558}
never executed: end of block
0
559-
560/*!-
561 \internal-
562-
563 Schedules an item for removal. This function leaves some stale indexes-
564 around in the BSP tree if called from the item's destructor; these will-
565 be cleaned up the next time someone triggers purgeRemovedItems().-
566-
567 Note: This function might get called from QGraphicsItem's destructor. \a item is-
568 being destroyed, so we cannot call any pure virtual functions on it (such-
569 as boundingRect()). Also, it is unnecessary to update the item's own state-
570 in any way.-
571*/-
572void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)-
573{-
574 Q_Q(QGraphicsScene);-
575-
576 // Clear focus on the item to remove any reference in the focusWidget chain.-
577 item->clearFocus();-
578-
579 markDirty(item, QRectF(), /*invalidateChildren=*/false, /*force=*/false,-
580 /*ignoreOpacity=*/false, /*removingItemFromScene=*/true);-
581-
582 if (item->d_ptr->inDestructor) {
item->d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
583 // The item is actually in its destructor, we call the special method in the index.-
584 index->deleteItem(item);-
585 } else {
never executed: end of block
0
586 // Can potentially call item->boundingRect() (virtual function), that's why-
587 // we only can call this function if the item is not in its destructor.-
588 index->removeItem(item);-
589 }
never executed: end of block
0
590-
591 item->d_ptr->clearSubFocus();-
592-
593 if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges)
item->flags() ...ositionChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
594 unregisterScenePosItem(item);
never executed: unregisterScenePosItem(item);
0
595-
596 QGraphicsScene *oldScene = item->d_func()->scene;-
597 item->d_func()->scene = 0;-
598-
599 //We need to remove all children first because they might use their parent-
600 //attributes (e.g. sceneTransform).-
601 if (!item->d_ptr->inDestructor) {
!item->d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
602 // Remove all children recursively-
603 for (int i = 0; i < item->d_ptr->children.size(); ++i)
i < item->d_pt...hildren.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
604 q->removeItem(item->d_ptr->children.at(i));
never executed: q->removeItem(item->d_ptr->children.at(i));
0
605 }
never executed: end of block
0
606-
607 if (!item->d_ptr->inDestructor && !item->parentItem() && item->isWidget()) {
!item->d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
!item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
608 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);-
609 widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0);-
610 }
never executed: end of block
0
611-
612 // Unregister focus proxy.-
613 item->d_ptr->resetFocusProxy();-
614-
615 // Remove from parent, or unregister from toplevels.-
616 if (QGraphicsItem *parentItem = item->parentItem()) {
QGraphicsItem ...->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
617 if (parentItem->scene()) {
parentItem->scene()Description
TRUEnever evaluated
FALSEnever evaluated
0
618 Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem",-
619 "Parent item's scene is different from this item's scene");-
620 item->setParentItem(0);-
621 }
never executed: end of block
0
622 } else {
never executed: end of block
0
623 unregisterTopLevelItem(item);-
624 }
never executed: end of block
0
625-
626 // Reset the mouse grabber and focus item data.-
627 if (item == focusItem)
item == focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
628 focusItem = 0;
never executed: focusItem = 0;
0
629 if (item == lastFocusItem)
item == lastFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
630 lastFocusItem = 0;
never executed: lastFocusItem = 0;
0
631 if (item == passiveFocusItem)
item == passiveFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
632 passiveFocusItem = 0;
never executed: passiveFocusItem = 0;
0
633 if (item == activePanel) {
item == activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
634 // ### deactivate...-
635 activePanel = 0;-
636 }
never executed: end of block
0
637 if (item == lastActivePanel)
item == lastActivePanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
638 lastActivePanel = 0;
never executed: lastActivePanel = 0;
0
639-
640 // Change tabFocusFirst to the next widget in focus chain if removing the current one.-
641 if (item == tabFocusFirst) {
item == tabFocusFirstDescription
TRUEnever evaluated
FALSEnever evaluated
0
642 QGraphicsWidgetPrivate *wd = tabFocusFirst->d_func();-
643 if (wd->focusNext && wd->focusNext != tabFocusFirst && wd->focusNext->scene() == q)
wd->focusNextDescription
TRUEnever evaluated
FALSEnever evaluated
wd->focusNext != tabFocusFirstDescription
TRUEnever evaluated
FALSEnever evaluated
wd->focusNext->scene() == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
644 tabFocusFirst = wd->focusNext;
never executed: tabFocusFirst = wd->focusNext;
0
645 else-
646 tabFocusFirst = 0;
never executed: tabFocusFirst = 0;
0
647 }-
648-
649 // Cancel active touches-
650 {-
651 QMap<int, QGraphicsItem *>::iterator it = itemForTouchPointId.begin();-
652 while (it != itemForTouchPointId.end()) {
it != itemForT...hPointId.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
653 if (it.value() == item) {
it.value() == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
654 sceneCurrentTouchPoints.remove(it.key());-
655 it = itemForTouchPointId.erase(it);-
656 } else {
never executed: end of block
0
657 ++it;-
658 }
never executed: end of block
0
659 }-
660 }-
661-
662 // Disable selectionChanged() for individual items-
663 ++selectionChanging;-
664 int oldSelectedItemsSize = selectedItems.size();-
665-
666 // Update selected & hovered item bookkeeping-
667 selectedItems.remove(item);-
668 hoverItems.removeAll(item);-
669 cachedItemsUnderMouse.removeAll(item);-
670 if (item->d_ptr->pendingPolish) {
item->d_ptr->pendingPolishDescription
TRUEnever evaluated
FALSEnever evaluated
0
671 const int unpolishedIndex = unpolishedItems.indexOf(item);-
672 if (unpolishedIndex != -1)
unpolishedIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
673 unpolishedItems[unpolishedIndex] = 0;
never executed: unpolishedItems[unpolishedIndex] = 0;
0
674 item->d_ptr->pendingPolish = false;-
675 }
never executed: end of block
0
676 resetDirtyItem(item);-
677-
678 //We remove all references of item from the sceneEventFilter arrays-
679 QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin();-
680 while (iterator != sceneEventFilters.end()) {
iterator != sc...tFilters.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
681 if (iterator.value() == item || iterator.key() == item)
iterator.value() == itemDescription
TRUEnever evaluated
FALSEnever evaluated
iterator.key() == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
682 iterator = sceneEventFilters.erase(iterator);
never executed: iterator = sceneEventFilters.erase(iterator);
0
683 else-
684 ++iterator;
never executed: ++iterator;
0
685 }-
686-
687 if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
item->panelMod...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
688 leaveModal(item);
never executed: leaveModal(item);
0
689-
690 // Reset the mouse grabber and focus item data.-
691 if (mouseGrabberItems.contains(item))
mouseGrabberIt...contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
692 ungrabMouse(item, /* item is dying */ item->d_ptr->inDestructor);
never executed: ungrabMouse(item, item->d_ptr->inDestructor);
0
693-
694 // Reset the keyboard grabber-
695 if (keyboardGrabberItems.contains(item))
keyboardGrabbe...contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
696 ungrabKeyboard(item, /* item is dying */ item->d_ptr->inDestructor);
never executed: ungrabKeyboard(item, item->d_ptr->inDestructor);
0
697-
698 // Reset the last mouse grabber item-
699 if (item == lastMouseGrabberItem)
item == lastMouseGrabberItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
700 lastMouseGrabberItem = 0;
never executed: lastMouseGrabberItem = 0;
0
701-
702 // Reset the current drop item-
703 if (item == dragDropItem)
item == dragDropItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
704 dragDropItem = 0;
never executed: dragDropItem = 0;
0
705-
706 // Reenable selectionChanged() for individual items-
707 --selectionChanging;-
708 if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize)
!selectionChangingDescription
TRUEnever evaluated
FALSEnever evaluated
selectedItems....ectedItemsSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
709 emit q->selectionChanged();
never executed: q->selectionChanged();
0
710-
711#ifndef QT_NO_GESTURES-
712 QHash<QGesture *, QGraphicsObject *>::iterator it;-
713 for (it = gestureTargets.begin(); it != gestureTargets.end();) {
it != gestureTargets.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
714 if (it.value() == item)
it.value() == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
715 it = gestureTargets.erase(it);
never executed: it = gestureTargets.erase(it);
0
716 else-
717 ++it;
never executed: ++it;
0
718 }-
719-
720 if (QGraphicsObject *dummy = item->toGraphicsObject()) {
QGraphicsObjec...aphicsObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
721 cachedTargetItems.removeOne(dummy);-
722 cachedItemGestures.remove(dummy);-
723 cachedAlreadyDeliveredGestures.remove(dummy);-
724 }
never executed: end of block
0
725-
726 foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())-
727 ungrabGesture(item, gesture);
never executed: ungrabGesture(item, gesture);
0
728#endif // QT_NO_GESTURES-
729}
never executed: end of block
0
730-
731/*!-
732 \internal-
733*/-
734void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent)-
735{-
736 Q_Q(QGraphicsScene);-
737 if (item && item->scene() != q) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
item->scene() != qDescription
TRUEnever evaluated
FALSEnever evaluated
0
738 qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene",-
739 item);-
740 return;
never executed: return;
0
741 }-
742-
743 // Ensure the scene has focus when we change panel activation.-
744 q->setFocus(Qt::ActiveWindowFocusReason);-
745-
746 // Find the item's panel.-
747 QGraphicsItem *panel = item ? item->panel() : 0;
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
748 lastActivePanel = panel ? activePanel : 0;
panelDescription
TRUEnever evaluated
FALSEnever evaluated
0
749 if (panel == activePanel || (!q->isActive() && !duringActivationEvent))
panel == activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
!q->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
!duringActivationEventDescription
TRUEnever evaluated
FALSEnever evaluated
0
750 return;
never executed: return;
0
751-
752 QGraphicsItem *oldFocusItem = focusItem;-
753-
754 // Deactivate the last active panel.-
755 if (activePanel) {
activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
756 if (QGraphicsItem *fi = activePanel->focusItem()) {
QGraphicsItem ...l->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
757 // Remove focus from the current focus item.-
758 if (fi == q->focusItem())
fi == q->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
759 setFocusItemHelper(0, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);
never executed: setFocusItemHelper(0, Qt::ActiveWindowFocusReason, false);
0
760 }
never executed: end of block
0
761-
762 QEvent event(QEvent::WindowDeactivate);-
763 q->sendEvent(activePanel, &event);-
764 } else if (panel && !duringActivationEvent) {
never executed: end of block
panelDescription
TRUEnever evaluated
FALSEnever evaluated
!duringActivationEventDescription
TRUEnever evaluated
FALSEnever evaluated
0
765 // Deactivate the scene if changing activation to a panel.-
766 const auto items = q->items();-
767 QEvent event(QEvent::WindowDeactivate);-
768 for (QGraphicsItem *item : items) {-
769 if (item->isVisible() && !item->isPanel() && !item->parentItem())
item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
!item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
770 q->sendEvent(item, &event);
never executed: q->sendEvent(item, &event);
0
771 }
never executed: end of block
0
772 }
never executed: end of block
0
773-
774 // Update activate state.-
775 activePanel = panel;-
776 QEvent event(QEvent::ActivationChange);-
777 QApplication::sendEvent(q, &event);-
778-
779 // Activate-
780 if (panel) {
panelDescription
TRUEnever evaluated
FALSEnever evaluated
0
781 QEvent event(QEvent::WindowActivate);-
782 q->sendEvent(panel, &event);-
783-
784 // Set focus on the panel's focus item, or itself if it's-
785 // focusable, or on the first focusable item in the panel's-
786 // focus chain as a last resort.-
787 if (QGraphicsItem *focusItem = panel->focusItem()) {
QGraphicsItem ...l->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
788 setFocusItemHelper(focusItem, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);-
789 } else if (panel->flags() & QGraphicsItem::ItemIsFocusable) {
never executed: end of block
panel->flags()...temIsFocusableDescription
TRUEnever evaluated
FALSEnever evaluated
0
790 setFocusItemHelper(panel, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);-
791 } else if (panel->isWidget()) {
never executed: end of block
panel->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
792 QGraphicsWidget *fw = static_cast<QGraphicsWidget *>(panel)->d_func()->focusNext;-
793 do {-
794 if (fw->focusPolicy() & Qt::TabFocus) {
fw->focusPolic...& Qt::TabFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
795 setFocusItemHelper(fw, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);-
796 break;
never executed: break;
0
797 }-
798 fw = fw->d_func()->focusNext;-
799 } while (fw != panel);
never executed: end of block
fw != panelDescription
TRUEnever evaluated
FALSEnever evaluated
0
800 }
never executed: end of block
0
801 } else if (q->isActive()) {
never executed: end of block
q->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
802 const auto items = q->items();-
803 // Activate the scene-
804 QEvent event(QEvent::WindowActivate);-
805 for (QGraphicsItem *item : items) {-
806 if (item->isVisible() && !item->isPanel() && !item->parentItem())
item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
!item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
807 q->sendEvent(item, &event);
never executed: q->sendEvent(item, &event);
0
808 }
never executed: end of block
0
809 }
never executed: end of block
0
810-
811 emit q->focusItemChanged(focusItem, oldFocusItem, Qt::ActiveWindowFocusReason);-
812}
never executed: end of block
0
813-
814/*!-
815 \internal-
816-
817 \a emitFocusChanged needs to be false when focus passes from one-
818 item to another through setActivePanel(); i.e. when activation-
819 passes from one panel to another, to avoid getting two focusChanged()-
820 emissions; one focusChanged(0, lastFocus), then one-
821 focusChanged(newFocus, 0). Instead setActivePanel() emits the signal-
822 once itself: focusChanged(newFocus, oldFocus).-
823*/-
824void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,-
825 Qt::FocusReason focusReason,-
826 bool emitFocusChanged)-
827{-
828 Q_Q(QGraphicsScene);-
829 if (item == focusItem)
item == focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
830 return;
never executed: return;
0
831-
832 // Clear focus if asked to set focus on something that can't-
833 // accept input focus.-
834 if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
!(item->flags(...emIsFocusable)Description
TRUEnever evaluated
FALSEnever evaluated
0
835 || !item->isVisible() || !item->isEnabled())) {
!item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!item->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
836 item = 0;-
837 }
never executed: end of block
0
838-
839 // Set focus on the scene if an item requests focus.-
840 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
841 q->setFocus(focusReason);-
842 if (item == focusItem) {
item == focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
843 if (emitFocusChanged)
emitFocusChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
844 emit q->focusItemChanged(focusItem, (QGraphicsItem *)0, focusReason);
never executed: q->focusItemChanged(focusItem, (QGraphicsItem *)0, focusReason);
0
845 return;
never executed: return;
0
846 }-
847 }
never executed: end of block
0
848-
849 QGraphicsItem *oldFocusItem = focusItem;-
850 if (focusItem) {
focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
851 lastFocusItem = focusItem;-
852-
853#ifndef QT_NO_IM-
854 if (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod) {
lastFocusItem-...ptsInputMethodDescription
TRUEnever evaluated
FALSEnever evaluated
0
855 // Close any external input method panel. This happens-
856 // automatically by removing WA_InputMethodEnabled on-
857 // the views, but if we are changing focus, we have to-
858 // do it ourselves.-
859 if (qApp)
(static_cast<Q...::instance()))Description
TRUEnever evaluated
FALSEnever evaluated
0
860 QGuiApplication::inputMethod()->commit();
never executed: QGuiApplication::inputMethod()->commit();
0
861 }
never executed: end of block
0
862#endif //QT_NO_IM-
863-
864 focusItem = 0;-
865 QFocusEvent event(QEvent::FocusOut, focusReason);-
866 sendEvent(lastFocusItem, &event);-
867 }
never executed: end of block
0
868-
869 // This handles the case that the item has been removed from the-
870 // scene in response to the FocusOut event.-
871 if (item && item->scene() != q)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
item->scene() != qDescription
TRUEnever evaluated
FALSEnever evaluated
0
872 item = 0;
never executed: item = 0;
0
873-
874 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
875 focusItem = item;
never executed: focusItem = item;
0
876 updateInputMethodSensitivityInViews();-
877-
878 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
879 QFocusEvent event(QEvent::FocusIn, focusReason);-
880 sendEvent(item, &event);-
881 }
never executed: end of block
0
882-
883 if (emitFocusChanged)
emitFocusChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
884 emit q->focusItemChanged(focusItem, oldFocusItem, focusReason);
never executed: q->focusItemChanged(focusItem, oldFocusItem, focusReason);
0
885}
never executed: end of block
0
886-
887/*!-
888 \internal-
889*/-
890void QGraphicsScenePrivate::addPopup(QGraphicsWidget *widget)-
891{-
892 Q_ASSERT(widget);-
893 Q_ASSERT(!popupWidgets.contains(widget));-
894 popupWidgets << widget;-
895 if (QGraphicsWidget *focusWidget = widget->focusWidget()) {
QGraphicsWidge...>focusWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
896 focusWidget->setFocus(Qt::PopupFocusReason);-
897 } else {
never executed: end of block
0
898 grabKeyboard((QGraphicsItem *)widget);-
899 if (focusItem && popupWidgets.size() == 1) {
focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
popupWidgets.size() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
900 QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason);-
901 sendEvent(focusItem, &event);-
902 }
never executed: end of block
0
903 }
never executed: end of block
0
904 grabMouse((QGraphicsItem *)widget);-
905}
never executed: end of block
0
906-
907/*!-
908 \internal-
909-
910 Remove \a widget from the popup list. Important notes:-
911-
912 \a widget is guaranteed to be in the list of popups, but it might not be-
913 the last entry; you can hide any item in the pop list before the others,-
914 and this must cause all later mouse grabbers to lose the grab.-
915*/-
916void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDying)-
917{-
918 Q_ASSERT(widget);-
919 int index = popupWidgets.indexOf(widget);-
920 Q_ASSERT(index != -1);-
921-
922 for (int i = popupWidgets.size() - 1; i >= index; --i) {
i >= indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
923 QGraphicsWidget *widget = popupWidgets.takeLast();-
924 ungrabMouse(widget, itemIsDying);-
925 if (focusItem && popupWidgets.isEmpty()) {
focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
popupWidgets.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
926 QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason);-
927 sendEvent(focusItem, &event);-
928 } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) {
never executed: end of block
keyboardGrabbe...em *>(widget))Description
TRUEnever evaluated
FALSEnever evaluated
0
929 ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying);-
930 }
never executed: end of block
0
931 if (!itemIsDying && widget->isVisible()) {
!itemIsDyingDescription
TRUEnever evaluated
FALSEnever evaluated
widget->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
932 widget->QGraphicsItem::d_ptr->setVisibleHelper(false, /* explicit = */ false);-
933 }
never executed: end of block
0
934 }
never executed: end of block
0
935}
never executed: end of block
0
936-
937/*!-
938 \internal-
939*/-
940void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit)-
941{-
942 // Append to list of mouse grabber items, and send a mouse grab event.-
943 if (mouseGrabberItems.contains(item)) {
mouseGrabberIt...contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
944 if (mouseGrabberItems.constLast() == item) {
mouseGrabberIt...Last() == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
945 Q_ASSERT(!implicit);-
946 if (!lastMouseGrabberItemHasImplicitMouseGrab) {
!lastMouseGrab...licitMouseGrabDescription
TRUEnever evaluated
FALSEnever evaluated
0
947 qWarning("QGraphicsItem::grabMouse: already a mouse grabber");-
948 } else {
never executed: end of block
0
949 // Upgrade to an explicit mouse grab-
950 lastMouseGrabberItemHasImplicitMouseGrab = false;-
951 }
never executed: end of block
0
952 } else {-
953 qWarning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p",-
954 mouseGrabberItems.constLast());-
955 }
never executed: end of block
0
956 return;
never executed: return;
0
957 }-
958-
959 // Send ungrab event to the last grabber.-
960 if (!mouseGrabberItems.isEmpty()) {
!mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
961 QGraphicsItem *last = mouseGrabberItems.constLast();-
962 if (lastMouseGrabberItemHasImplicitMouseGrab) {
lastMouseGrabb...licitMouseGrabDescription
TRUEnever evaluated
FALSEnever evaluated
0
963 // Implicit mouse grab is immediately lost.-
964 last->ungrabMouse();-
965 } else {
never executed: end of block
0
966 // Just send ungrab event to current grabber.-
967 QEvent ungrabEvent(QEvent::UngrabMouse);-
968 sendEvent(last, &ungrabEvent);-
969 }
never executed: end of block
0
970 }-
971-
972 mouseGrabberItems << item;-
973 lastMouseGrabberItemHasImplicitMouseGrab = implicit;-
974-
975 // Send grab event to current grabber.-
976 QEvent grabEvent(QEvent::GrabMouse);-
977 sendEvent(item, &grabEvent);-
978}
never executed: end of block
0
979-
980/*!-
981 \internal-
982*/-
983void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying)-
984{-
985 int index = mouseGrabberItems.indexOf(item);-
986 if (index == -1) {
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
987 qWarning("QGraphicsItem::ungrabMouse: not a mouse grabber");-
988 return;
never executed: return;
0
989 }-
990-
991 if (item != mouseGrabberItems.constLast()) {
item != mouseG...ms.constLast()Description
TRUEnever evaluated
FALSEnever evaluated
0
992 // Recursively ungrab the next mouse grabber until we reach this item-
993 // to ensure state consistency.-
994 ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying);-
995 }
never executed: end of block
0
996 if (!popupWidgets.isEmpty() && item == popupWidgets.constLast()) {
!popupWidgets.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
item == popupW...ts.constLast()Description
TRUEnever evaluated
FALSEnever evaluated
0
997 // If the item is a popup, go via removePopup to ensure state-
998 // consistency and that it gets hidden correctly - beware that-
999 // removePopup() reenters this function to continue removing the grab.-
1000 removePopup(popupWidgets.constLast(), itemIsDying);-
1001 return;
never executed: return;
0
1002 }-
1003-
1004 // Send notification about mouse ungrab.-
1005 if (!itemIsDying) {
!itemIsDyingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1006 QEvent event(QEvent::UngrabMouse);-
1007 sendEvent(item, &event);-
1008 }
never executed: end of block
0
1009-
1010 // Remove the item from the list of grabbers. Whenever this happens, we-
1011 // reset the implicitGrab (there can be only ever be one implicit grabber-
1012 // in a scene, and it is always the latest grabber; if the implicit grab-
1013 // is lost, it is not automatically regained.-
1014 mouseGrabberItems.takeLast();-
1015 lastMouseGrabberItemHasImplicitMouseGrab = false;-
1016-
1017 // Send notification about mouse regrab. ### It's unfortunate that all the-
1018 // items get a GrabMouse event, but this is a rare case with a simple-
1019 // implementation and it does ensure a consistent state.-
1020 if (!itemIsDying && !mouseGrabberItems.isEmpty()) {
!itemIsDyingDescription
TRUEnever evaluated
FALSEnever evaluated
!mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1021 QGraphicsItem *last = mouseGrabberItems.constLast();-
1022 QEvent event(QEvent::GrabMouse);-
1023 sendEvent(last, &event);-
1024 }
never executed: end of block
0
1025}
never executed: end of block
0
1026-
1027/*!-
1028 \internal-
1029*/-
1030void QGraphicsScenePrivate::clearMouseGrabber()-
1031{-
1032 if (!mouseGrabberItems.isEmpty())
!mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1033 mouseGrabberItems.first()->ungrabMouse();
never executed: mouseGrabberItems.first()->ungrabMouse();
0
1034 lastMouseGrabberItem = 0;-
1035}
never executed: end of block
0
1036-
1037/*!-
1038 \internal-
1039*/-
1040void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item)-
1041{-
1042 if (keyboardGrabberItems.contains(item)) {
keyboardGrabbe...contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
1043 if (keyboardGrabberItems.constLast() == item)
keyboardGrabbe...Last() == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1044 qWarning("QGraphicsItem::grabKeyboard: already a keyboard grabber");
never executed: QMessageLogger(__FILE__, 1044, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already a keyboard grabber");
0
1045 else-
1046 qWarning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p",
never executed: QMessageLogger(__FILE__, 1046, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p", keyboardGrabberItems.constLast());
0
1047 keyboardGrabberItems.constLast());
never executed: QMessageLogger(__FILE__, 1046, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p", keyboardGrabberItems.constLast());
0
1048 return;
never executed: return;
0
1049 }-
1050-
1051 // Send ungrab event to the last grabber.-
1052 if (!keyboardGrabberItems.isEmpty()) {
!keyboardGrabb...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1053 // Just send ungrab event to current grabber.-
1054 QEvent ungrabEvent(QEvent::UngrabKeyboard);-
1055 sendEvent(keyboardGrabberItems.constLast(), &ungrabEvent);-
1056 }
never executed: end of block
0
1057-
1058 keyboardGrabberItems << item;-
1059-
1060 // Send grab event to current grabber.-
1061 QEvent grabEvent(QEvent::GrabKeyboard);-
1062 sendEvent(item, &grabEvent);-
1063}
never executed: end of block
0
1064-
1065/*!-
1066 \internal-
1067*/-
1068void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying)-
1069{-
1070 int index = keyboardGrabberItems.lastIndexOf(item);-
1071 if (index == -1) {
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1072 qWarning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber");-
1073 return;
never executed: return;
0
1074 }-
1075 if (item != keyboardGrabberItems.constLast()) {
item != keyboa...ms.constLast()Description
TRUEnever evaluated
FALSEnever evaluated
0
1076 // Recursively ungrab the topmost keyboard grabber until we reach this-
1077 // item to ensure state consistency.-
1078 ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying);-
1079 }
never executed: end of block
0
1080-
1081 // Send notification about keyboard ungrab.-
1082 if (!itemIsDying) {
!itemIsDyingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1083 QEvent event(QEvent::UngrabKeyboard);-
1084 sendEvent(item, &event);-
1085 }
never executed: end of block
0
1086-
1087 // Remove the item from the list of grabbers.-
1088 keyboardGrabberItems.takeLast();-
1089-
1090 // Send notification about mouse regrab.-
1091 if (!itemIsDying && !keyboardGrabberItems.isEmpty()) {
!itemIsDyingDescription
TRUEnever evaluated
FALSEnever evaluated
!keyboardGrabb...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1092 QGraphicsItem *last = keyboardGrabberItems.constLast();-
1093 QEvent event(QEvent::GrabKeyboard);-
1094 sendEvent(last, &event);-
1095 }
never executed: end of block
0
1096}
never executed: end of block
0
1097-
1098/*!-
1099 \internal-
1100*/-
1101void QGraphicsScenePrivate::clearKeyboardGrabber()-
1102{-
1103 if (!keyboardGrabberItems.isEmpty())
!keyboardGrabb...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1104 ungrabKeyboard(keyboardGrabberItems.constFirst());
never executed: ungrabKeyboard(keyboardGrabberItems.constFirst());
0
1105}
never executed: end of block
0
1106-
1107void QGraphicsScenePrivate::enableMouseTrackingOnViews()-
1108{-
1109 foreach (QGraphicsView *view, views)-
1110 view->viewport()->setMouseTracking(true);
never executed: view->viewport()->setMouseTracking(true);
0
1111}
never executed: end of block
0
1112-
1113/*!-
1114 Returns all items for the screen position in \a event.-
1115*/-
1116QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &screenPos,-
1117 const QPointF &scenePos,-
1118 QWidget *widget) const-
1119{-
1120 Q_Q(const QGraphicsScene);-
1121 QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1122 if (!view)
!viewDescription
TRUEnever evaluated
FALSEnever evaluated
0
1123 return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform());
never executed: return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform());
0
1124-
1125 const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1));-
1126 if (!view->isTransformed())
!view->isTransformed()Description
TRUEnever evaluated
FALSEnever evaluated
0
1127 return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder);
never executed: return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder);
0
1128-
1129 const QTransform viewTransform = view->viewportTransform();-
1130 if (viewTransform.type() <= QTransform::TxScale) {
viewTransform....sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1131 return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape,
never executed: return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
0
1132 Qt::DescendingOrder, viewTransform);
never executed: return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
0
1133 }-
1134 return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape,
never executed: return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
0
1135 Qt::DescendingOrder, viewTransform);
never executed: return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
0
1136}-
1137-
1138/*!-
1139 \internal-
1140*/-
1141void QGraphicsScenePrivate::storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event)-
1142{-
1143 for (int i = 0x1; i <= 0x10; i <<= 1) {
i <= 0x10Description
TRUEnever evaluated
FALSEnever evaluated
0
1144 if (event->buttons() & i) {
event->buttons() & iDescription
TRUEnever evaluated
FALSEnever evaluated
0
1145 mouseGrabberButtonDownPos.insert(Qt::MouseButton(i),-
1146 mouseGrabberItems.constLast()->d_ptr->genericMapFromScene(event->scenePos(),-
1147 event->widget()));-
1148 mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos());-
1149 mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos());-
1150 }
never executed: end of block
0
1151 }
never executed: end of block
0
1152}
never executed: end of block
0
1153-
1154/*!-
1155 \internal-
1156*/-
1157void QGraphicsScenePrivate::installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter)-
1158{-
1159 sceneEventFilters.insert(watched, filter);-
1160}
never executed: end of block
0
1161-
1162/*!-
1163 \internal-
1164*/-
1165void QGraphicsScenePrivate::removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter)-
1166{-
1167 if (!sceneEventFilters.contains(watched))
!sceneEventFil...tains(watched)Description
TRUEnever evaluated
FALSEnever evaluated
0
1168 return;
never executed: return;
0
1169-
1170 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(watched);-
1171 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(watched);-
1172 do {-
1173 if (it.value() == filter)
it.value() == filterDescription
TRUEnever evaluated
FALSEnever evaluated
0
1174 it = sceneEventFilters.erase(it);
never executed: it = sceneEventFilters.erase(it);
0
1175 else-
1176 ++it;
never executed: ++it;
0
1177 } while (it != end);
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
1178}
never executed: end of block
0
1179-
1180/*!-
1181 \internal-
1182*/-
1183bool QGraphicsScenePrivate::filterDescendantEvent(QGraphicsItem *item, QEvent *event)-
1184{-
1185 if (item && (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
(item->d_ptr->...rsChildEvents)Description
TRUEnever evaluated
FALSEnever evaluated
0
1186 QGraphicsItem *parent = item->parentItem();-
1187 while (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1188 if (parent->d_ptr->filtersDescendantEvents && parent->sceneEventFilter(item, event))
parent->d_ptr-...scendantEventsDescription
TRUEnever evaluated
FALSEnever evaluated
parent->sceneE...r(item, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1189 return true;
never executed: return true;
0
1190 if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents))
!(parent->d_pt...rsChildEvents)Description
TRUEnever evaluated
FALSEnever evaluated
0
1191 return false;
never executed: return false;
0
1192 parent = parent->parentItem();-
1193 }
never executed: end of block
0
1194 }
never executed: end of block
0
1195 return false;
never executed: return false;
0
1196}-
1197-
1198/*!-
1199 \internal-
1200*/-
1201bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event)-
1202{-
1203 if (item && !sceneEventFilters.contains(item))
itemDescription
TRUEnever evaluated
FALSEnever evaluated
!sceneEventFil...contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
1204 return false;
never executed: return false;
0
1205-
1206 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(item);-
1207 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(item);-
1208 while (it != end) {
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
1209 // ### The filterer and filteree might both be deleted.-
1210 if (it.value()->sceneEventFilter(it.key(), event))
it.value()->sc....key(), event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1211 return true;
never executed: return true;
0
1212 ++it;-
1213 }
never executed: end of block
0
1214 return false;
never executed: return false;
0
1215}-
1216-
1217/*!-
1218 \internal-
1219-
1220 This is the final dispatch point for any events from the scene to the-
1221 item. It filters the event first - if the filter returns \c true, the event-
1222 is considered to have been eaten by the filter, and is therefore stopped-
1223 (the default filter returns \c false). Then/otherwise, if the item is-
1224 enabled, the event is sent; otherwise it is stopped.-
1225*/-
1226bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event)-
1227{-
1228 if (QGraphicsObject *object = item->toGraphicsObject()) {
QGraphicsObjec...aphicsObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
1229#ifndef QT_NO_GESTURES-
1230 QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;-
1231 if (gestureManager) {
gestureManagerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1232 if (gestureManager->filterEvent(object, event))
gestureManager...object, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1233 return true;
never executed: return true;
0
1234 }
never executed: end of block
0
1235#endif // QT_NO_GESTURES-
1236 }
never executed: end of block
0
1237-
1238 if (filterEvent(item, event))
filterEvent(item, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1239 return false;
never executed: return false;
0
1240 if (filterDescendantEvent(item, event))
filterDescenda...t(item, event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1241 return false;
never executed: return false;
0
1242 if (!item || !item->isEnabled())
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
!item->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
1243 return false;
never executed: return false;
0
1244 if (QGraphicsObject *o = item->toGraphicsObject()) {
QGraphicsObjec...aphicsObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
1245 bool spont = event->spontaneous();-
1246 if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event))
spont ? qt_sen...vent(o, event)Description
TRUEnever evaluated
FALSEnever evaluated
spontDescription
TRUEnever evaluated
FALSEnever evaluated
0
1247 return true;
never executed: return true;
0
1248 event->spont = spont;-
1249 }
never executed: end of block
0
1250 return item->sceneEvent(event);
never executed: return item->sceneEvent(event);
0
1251}-
1252-
1253/*!-
1254 \internal-
1255*/-
1256void QGraphicsScenePrivate::cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest,-
1257 QGraphicsSceneDragDropEvent *source)-
1258{-
1259 dest->setWidget(source->widget());-
1260 dest->setPos(source->pos());-
1261 dest->setScenePos(source->scenePos());-
1262 dest->setScreenPos(source->screenPos());-
1263 dest->setButtons(source->buttons());-
1264 dest->setModifiers(source->modifiers());-
1265 dest->setPossibleActions(source->possibleActions());-
1266 dest->setProposedAction(source->proposedAction());-
1267 dest->setDropAction(source->dropAction());-
1268 dest->setSource(source->source());-
1269 dest->setMimeData(source->mimeData());-
1270}
never executed: end of block
0
1271-
1272/*!-
1273 \internal-
1274*/-
1275void QGraphicsScenePrivate::sendDragDropEvent(QGraphicsItem *item,-
1276 QGraphicsSceneDragDropEvent *dragDropEvent)-
1277{-
1278 dragDropEvent->setPos(item->d_ptr->genericMapFromScene(dragDropEvent->scenePos(), dragDropEvent->widget()));-
1279 sendEvent(item, dragDropEvent);-
1280}
never executed: end of block
0
1281-
1282/*!-
1283 \internal-
1284*/-
1285void QGraphicsScenePrivate::sendHoverEvent(QEvent::Type type, QGraphicsItem *item,-
1286 QGraphicsSceneHoverEvent *hoverEvent)-
1287{-
1288 QGraphicsSceneHoverEvent event(type);-
1289 event.setWidget(hoverEvent->widget());-
1290 event.setPos(item->d_ptr->genericMapFromScene(hoverEvent->scenePos(), hoverEvent->widget()));-
1291 event.setScenePos(hoverEvent->scenePos());-
1292 event.setScreenPos(hoverEvent->screenPos());-
1293 event.setLastPos(item->d_ptr->genericMapFromScene(hoverEvent->lastScenePos(), hoverEvent->widget()));-
1294 event.setLastScenePos(hoverEvent->lastScenePos());-
1295 event.setLastScreenPos(hoverEvent->lastScreenPos());-
1296 event.setModifiers(hoverEvent->modifiers());-
1297 sendEvent(item, &event);-
1298}
never executed: end of block
0
1299-
1300/*!-
1301 \internal-
1302*/-
1303void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent)-
1304{-
1305 if (mouseEvent->button() == 0 && mouseEvent->buttons() == 0 && lastMouseGrabberItemHasImplicitMouseGrab) {
mouseEvent->button() == 0Description
TRUEnever evaluated
FALSEnever evaluated
mouseEvent->buttons() == 0Description
TRUEnever evaluated
FALSEnever evaluated
lastMouseGrabb...licitMouseGrabDescription
TRUEnever evaluated
FALSEnever evaluated
0
1306 // ### This is a temporary fix for until we get proper mouse-
1307 // grab events.-
1308 clearMouseGrabber();-
1309 return;
never executed: return;
0
1310 }-
1311-
1312 QGraphicsItem *item = mouseGrabberItems.constLast();-
1313 if (item->isBlockedByModalPanel())
item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1314 return;
never executed: return;
0
1315-
1316 for (int i = 0x1; i <= 0x10; i <<= 1) {
i <= 0x10Description
TRUEnever evaluated
FALSEnever evaluated
0
1317 Qt::MouseButton button = Qt::MouseButton(i);-
1318 mouseEvent->setButtonDownPos(button, mouseGrabberButtonDownPos.value(button, item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget())));-
1319 mouseEvent->setButtonDownScenePos(button, mouseGrabberButtonDownScenePos.value(button, mouseEvent->scenePos()));-
1320 mouseEvent->setButtonDownScreenPos(button, mouseGrabberButtonDownScreenPos.value(button, mouseEvent->screenPos()));-
1321 }
never executed: end of block
0
1322 mouseEvent->setPos(item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget()));-
1323 mouseEvent->setLastPos(item->d_ptr->genericMapFromScene(mouseEvent->lastScenePos(), mouseEvent->widget()));-
1324 sendEvent(item, mouseEvent);-
1325}
never executed: end of block
0
1326-
1327/*!-
1328 \internal-
1329*/-
1330void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent)-
1331{-
1332 Q_Q(QGraphicsScene);-
1333-
1334 // Ignore by default, unless we find a mouse grabber that accepts it.-
1335 mouseEvent->ignore();-
1336-
1337 // Deliver to any existing mouse grabber.-
1338 if (!mouseGrabberItems.isEmpty()) {
!mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1339 if (mouseGrabberItems.constLast()->isBlockedByModalPanel())
mouseGrabberIt...ByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1340 return;
never executed: return;
0
1341 // The event is ignored by default, but we disregard the event's-
1342 // accepted state after delivery; the mouse is grabbed, after all.-
1343 sendMouseEvent(mouseEvent);-
1344 return;
never executed: return;
0
1345 }-
1346-
1347 // Start by determining the number of items at the current position.-
1348 // Reuse value from earlier calculations if possible.-
1349 if (cachedItemsUnderMouse.isEmpty()) {
cachedItemsUnd...ouse.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1350 cachedItemsUnderMouse = itemsAtPosition(mouseEvent->screenPos(),-
1351 mouseEvent->scenePos(),-
1352 mouseEvent->widget());-
1353 }
never executed: end of block
0
1354-
1355 // Update window activation.-
1356 QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);-
1357 QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0;
topItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1358 if (newActiveWindow && newActiveWindow->isBlockedByModalPanel(&topItem)) {
newActiveWindowDescription
TRUEnever evaluated
FALSEnever evaluated
newActiveWindo...anel(&topItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
1359 // pass activation to the blocking modal window-
1360 newActiveWindow = topItem ? topItem->window() : 0;
topItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1361 }
never executed: end of block
0
1362-
1363 if (newActiveWindow != q->activeWindow())
newActiveWindo...activeWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
1364 q->setActiveWindow(newActiveWindow);
never executed: q->setActiveWindow(newActiveWindow);
0
1365-
1366 // Set focus on the topmost enabled item that can take focus.-
1367 bool setFocus = false;-
1368-
1369 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {-
1370 if (item->isBlockedByModalPanel()
item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1371 || (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)) {
(item->d_ptr->...FocusHandling)Description
TRUEnever evaluated
FALSEnever evaluated
0
1372 // Make sure we don't clear focus.-
1373 setFocus = true;-
1374 break;
never executed: break;
0
1375 }-
1376 if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable))) {
item->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
((item->flags(...mIsFocusable))Description
TRUEnever evaluated
FALSEnever evaluated
0
1377 if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
!item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
((QGraphicsWid...Qt::ClickFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1378 setFocus = true;-
1379 if (item != q->focusItem() && item->d_ptr->mouseSetsFocus)
item != q->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->mouseSetsFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1380 q->setFocusItem(item, Qt::MouseFocusReason);
never executed: q->setFocusItem(item, Qt::MouseFocusReason);
0
1381 break;
never executed: break;
0
1382 }-
1383 }
never executed: end of block
0
1384 if (item->isPanel())
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
1385 break;
never executed: break;
0
1386 if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
item->d_ptr->f...cusPropagationDescription
TRUEnever evaluated
FALSEnever evaluated
0
1387 break;
never executed: break;
0
1388 }
never executed: end of block
0
1389-
1390 // Check for scene modality.-
1391 bool sceneModality = false;-
1392 for (int i = 0; i < modalPanels.size(); ++i) {
i < modalPanels.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1393 if (modalPanels.at(i)->panelModality() == QGraphicsItem::SceneModal) {
modalPanels.at...em::SceneModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1394 sceneModality = true;-
1395 break;
never executed: break;
0
1396 }-
1397 }
never executed: end of block
0
1398-
1399 // If nobody could take focus, clear it.-
1400 if (!stickyFocus && !setFocus && !sceneModality)
!stickyFocusDescription
TRUEnever evaluated
FALSEnever evaluated
!setFocusDescription
TRUEnever evaluated
FALSEnever evaluated
!sceneModalityDescription
TRUEnever evaluated
FALSEnever evaluated
0
1401 q->setFocusItem(0, Qt::MouseFocusReason);
never executed: q->setFocusItem(0, Qt::MouseFocusReason);
0
1402-
1403 // Any item will do.-
1404 if (sceneModality && cachedItemsUnderMouse.isEmpty())
sceneModalityDescription
TRUEnever evaluated
FALSEnever evaluated
cachedItemsUnd...ouse.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1405 cachedItemsUnderMouse << modalPanels.constFirst();
never executed: cachedItemsUnderMouse << modalPanels.constFirst();
0
1406-
1407 // Find a mouse grabber by sending mouse press events to all mouse grabber-
1408 // candidates one at a time, until the event is accepted. It's accepted by-
1409 // default, so the receiver has to explicitly ignore it for it to pass-
1410 // through.-
1411 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {-
1412 if (!(item->acceptedMouseButtons() & mouseEvent->button())) {
!(item->accept...ent->button())Description
TRUEnever evaluated
FALSEnever evaluated
0
1413 // Skip items that don't accept the event's mouse button.-
1414 continue;
never executed: continue;
0
1415 }-
1416-
1417 // Check if this item is blocked by a modal panel and deliver the mouse event to the-
1418 // blocking panel instead of this item if blocked.-
1419 (void) item->isBlockedByModalPanel(&item);-
1420-
1421 grabMouse(item, /* implicit = */ true);-
1422 mouseEvent->accept();-
1423-
1424 // check if the item we are sending to are disabled (before we send the event)-
1425 bool disabled = !item->isEnabled();-
1426 bool isPanel = item->isPanel();-
1427 if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick
mouseEvent->ty...useDoubleClickDescription
TRUEnever evaluated
FALSEnever evaluated
0
1428 && item != lastMouseGrabberItem && lastMouseGrabberItem) {
item != lastMouseGrabberItemDescription
TRUEnever evaluated
FALSEnever evaluated
lastMouseGrabberItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1429 // If this item is different from the item that received the last-
1430 // mouse event, and mouseEvent is a doubleclick event, then the-
1431 // event is converted to a press. Known limitation:-
1432 // Triple-clicking will not generate a doubleclick, though.-
1433 QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress);-
1434 mousePress.spont = mouseEvent->spont;-
1435 mousePress.accept();-
1436 mousePress.setButton(mouseEvent->button());-
1437 mousePress.setButtons(mouseEvent->buttons());-
1438 mousePress.setScreenPos(mouseEvent->screenPos());-
1439 mousePress.setScenePos(mouseEvent->scenePos());-
1440 mousePress.setModifiers(mouseEvent->modifiers());-
1441 mousePress.setWidget(mouseEvent->widget());-
1442 mousePress.setButtonDownPos(mouseEvent->button(),-
1443 mouseEvent->buttonDownPos(mouseEvent->button()));-
1444 mousePress.setButtonDownScenePos(mouseEvent->button(),-
1445 mouseEvent->buttonDownScenePos(mouseEvent->button()));-
1446 mousePress.setButtonDownScreenPos(mouseEvent->button(),-
1447 mouseEvent->buttonDownScreenPos(mouseEvent->button()));-
1448 sendMouseEvent(&mousePress);-
1449 mouseEvent->setAccepted(mousePress.isAccepted());-
1450 } else {
never executed: end of block
0
1451 sendMouseEvent(mouseEvent);-
1452 }
never executed: end of block
0
1453-
1454 bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.constLast() != item;
mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
mouseGrabberIt...Last() != itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1455 if (disabled) {
disabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1456 ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);-
1457 break;
never executed: break;
0
1458 }-
1459 if (mouseEvent->isAccepted()) {
mouseEvent->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
1460 if (!mouseGrabberItems.isEmpty())
!mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1461 storeMouseButtonsForMouseGrabber(mouseEvent);
never executed: storeMouseButtonsForMouseGrabber(mouseEvent);
0
1462 lastMouseGrabberItem = item;-
1463 return;
never executed: return;
0
1464 }-
1465 ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);-
1466-
1467 // Don't propagate through panels.-
1468 if (isPanel)
isPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1469 break;
never executed: break;
0
1470 }
never executed: end of block
0
1471-
1472 // Is the event still ignored? Then the mouse press goes to the scene.-
1473 // Reset the mouse grabber, clear the selection, clear focus, and leave-
1474 // the event ignored so that it can propagate through the originating-
1475 // view.-
1476 if (!mouseEvent->isAccepted()) {
!mouseEvent->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
1477 clearMouseGrabber();-
1478-
1479 QGraphicsView *view = mouseEvent->widget() ? qobject_cast<QGraphicsView *>(mouseEvent->widget()->parentWidget()) : 0;
mouseEvent->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1480 bool dontClearSelection = view && view->dragMode() == QGraphicsView::ScrollHandDrag;
viewDescription
TRUEnever evaluated
FALSEnever evaluated
view->dragMode...ScrollHandDragDescription
TRUEnever evaluated
FALSEnever evaluated
0
1481 bool extendSelection = (mouseEvent->modifiers() & Qt::ControlModifier) != 0;-
1482 dontClearSelection |= extendSelection;-
1483 if (!dontClearSelection) {
!dontClearSelectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1484 // Clear the selection if the originating view isn't in scroll-
1485 // hand drag mode. The view will clear the selection if no drag-
1486 // happened.-
1487 q->clearSelection();-
1488 }
never executed: end of block
0
1489 }
never executed: end of block
0
1490}
never executed: end of block
0
1491-
1492/*!-
1493 \internal-
1494-
1495 Ensures that the list of toplevels is sorted by insertion order, and that-
1496 the siblingIndexes are packed (no gaps), and start at 0.-
1497-
1498 ### This function is almost identical to-
1499 QGraphicsItemPrivate::ensureSequentialSiblingIndex().-
1500*/-
1501void QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes()-
1502{-
1503 if (!topLevelSequentialOrdering) {
!topLevelSequentialOrderingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1504 std::sort(topLevelItems.begin(), topLevelItems.end(), QGraphicsItemPrivate::insertionOrder);-
1505 topLevelSequentialOrdering = true;-
1506 needSortTopLevelItems = 1;-
1507 }
never executed: end of block
0
1508 if (holesInTopLevelSiblingIndex) {
holesInTopLevelSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1509 holesInTopLevelSiblingIndex = 0;-
1510 for (int i = 0; i < topLevelItems.size(); ++i)
i < topLevelItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1511 topLevelItems[i]->d_ptr->siblingIndex = i;
never executed: topLevelItems[i]->d_ptr->siblingIndex = i;
0
1512 }
never executed: end of block
0
1513}
never executed: end of block
0
1514-
1515/*!-
1516 \internal-
1517-
1518 Set the font and propagate the changes if the font is different from the-
1519 current font.-
1520*/-
1521void QGraphicsScenePrivate::setFont_helper(const QFont &font)-
1522{-
1523 if (this->font == font && this->font.resolve() == font.resolve())
this->font == fontDescription
TRUEnever evaluated
FALSEnever evaluated
this->font.res...font.resolve()Description
TRUEnever evaluated
FALSEnever evaluated
0
1524 return;
never executed: return;
0
1525 updateFont(font);-
1526}
never executed: end of block
0
1527-
1528/*!-
1529 \internal-
1530-
1531 Resolve the scene's font against the application font, and propagate the-
1532 changes too all items in the scene.-
1533*/-
1534void QGraphicsScenePrivate::resolveFont()-
1535{-
1536 QFont naturalFont = QApplication::font();-
1537 naturalFont.resolve(0);-
1538 QFont resolvedFont = font.resolve(naturalFont);-
1539 updateFont(resolvedFont);-
1540}
never executed: end of block
0
1541-
1542/*!-
1543 \internal-
1544-
1545 Update the font, and whether or not it has changed, reresolve all fonts in-
1546 the scene.-
1547*/-
1548void QGraphicsScenePrivate::updateFont(const QFont &font)-
1549{-
1550 Q_Q(QGraphicsScene);-
1551-
1552 // Update local font setting.-
1553 this->font = font;-
1554-
1555 // Resolve the fonts of all top-level widget items, or widget items-
1556 // whose parent is not a widget.-
1557 const auto items = q->items();-
1558 for (QGraphicsItem *item : items) {-
1559 if (!item->parentItem()) {
!item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1560 // Resolvefont for an item is a noop operation, but-
1561 // every item can be a widget, or can have a widget-
1562 // childre.-
1563 item->d_ptr->resolveFont(font.resolve());-
1564 }
never executed: end of block
0
1565 }
never executed: end of block
0
1566-
1567 // Send the scene a FontChange event.-
1568 QEvent event(QEvent::FontChange);-
1569 QApplication::sendEvent(q, &event);-
1570}
never executed: end of block
0
1571-
1572/*!-
1573 \internal-
1574-
1575 Set the palette and propagate the changes if the palette is different from-
1576 the current palette.-
1577*/-
1578void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette)-
1579{-
1580 if (this->palette == palette && this->palette.resolve() == palette.resolve())
this->palette == paletteDescription
TRUEnever evaluated
FALSEnever evaluated
this->palette....ette.resolve()Description
TRUEnever evaluated
FALSEnever evaluated
0
1581 return;
never executed: return;
0
1582 updatePalette(palette);-
1583}
never executed: end of block
0
1584-
1585/*!-
1586 \internal-
1587-
1588 Resolve the scene's palette against the application palette, and propagate-
1589 the changes too all items in the scene.-
1590*/-
1591void QGraphicsScenePrivate::resolvePalette()-
1592{-
1593 QPalette naturalPalette = QApplication::palette();-
1594 naturalPalette.resolve(0);-
1595 QPalette resolvedPalette = palette.resolve(naturalPalette);-
1596 updatePalette(resolvedPalette);-
1597}
never executed: end of block
0
1598-
1599/*!-
1600 \internal-
1601-
1602 Update the palette, and whether or not it has changed, reresolve all-
1603 palettes in the scene.-
1604*/-
1605void QGraphicsScenePrivate::updatePalette(const QPalette &palette)-
1606{-
1607 Q_Q(QGraphicsScene);-
1608-
1609 // Update local palette setting.-
1610 this->palette = palette;-
1611-
1612 // Resolve the palettes of all top-level widget items, or widget items-
1613 // whose parent is not a widget.-
1614 const auto items = q->items();-
1615 for (QGraphicsItem *item : items) {-
1616 if (!item->parentItem()) {
!item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1617 // ResolvePalette for an item is a noop operation, but-
1618 // every item can be a widget, or can have a widget-
1619 // children.-
1620 item->d_ptr->resolvePalette(palette.resolve());-
1621 }
never executed: end of block
0
1622 }
never executed: end of block
0
1623-
1624 // Send the scene a PaletteChange event.-
1625 QEvent event(QEvent::PaletteChange);-
1626 QApplication::sendEvent(q, &event);-
1627}
never executed: end of block
0
1628-
1629/*!-
1630 Constructs a QGraphicsScene object. The \a parent parameter is-
1631 passed to QObject's constructor.-
1632*/-
1633QGraphicsScene::QGraphicsScene(QObject *parent)-
1634 : QObject(*new QGraphicsScenePrivate, parent)-
1635{-
1636 d_func()->init();-
1637}
never executed: end of block
0
1638-
1639/*!-
1640 Constructs a QGraphicsScene object, using \a sceneRect for its-
1641 scene rectangle. The \a parent parameter is passed to QObject's-
1642 constructor.-
1643-
1644 \sa sceneRect-
1645*/-
1646QGraphicsScene::QGraphicsScene(const QRectF &sceneRect, QObject *parent)-
1647 : QObject(*new QGraphicsScenePrivate, parent)-
1648{-
1649 d_func()->init();-
1650 setSceneRect(sceneRect);-
1651}
never executed: end of block
0
1652-
1653/*!-
1654 Constructs a QGraphicsScene object, using the rectangle specified-
1655 by (\a x, \a y), and the given \a width and \a height for its-
1656 scene rectangle. The \a parent parameter is passed to QObject's-
1657 constructor.-
1658-
1659 \sa sceneRect-
1660*/-
1661QGraphicsScene::QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent)-
1662 : QObject(*new QGraphicsScenePrivate, parent)-
1663{-
1664 d_func()->init();-
1665 setSceneRect(x, y, width, height);-
1666}
never executed: end of block
0
1667-
1668/*!-
1669 Removes and deletes all items from the scene object-
1670 before destroying the scene object. The scene object-
1671 is removed from the application's global scene list,-
1672 and it is removed from all associated views.-
1673*/-
1674QGraphicsScene::~QGraphicsScene()-
1675{-
1676 Q_D(QGraphicsScene);-
1677-
1678 // Remove this scene from qApp's global scene list.-
1679 if (!QApplicationPrivate::is_app_closing)
!QApplicationP...is_app_closingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1680 qApp->d_func()->scene_list.removeAll(this);
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->scene_list.removeAll(this);
0
1681-
1682 clear();-
1683-
1684 // Remove this scene from all associated views.-
1685 for (int j = 0; j < d->views.size(); ++j)
j < d->views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1686 d->views.at(j)->setScene(0);
never executed: d->views.at(j)->setScene(0);
0
1687}
never executed: end of block
0
1688-
1689/*!-
1690 \property QGraphicsScene::sceneRect-
1691 \brief the scene rectangle; the bounding rectangle of the scene-
1692-
1693 The scene rectangle defines the extent of the scene. It is-
1694 primarily used by QGraphicsView to determine the view's default-
1695 scrollable area, and by QGraphicsScene to manage item indexing.-
1696-
1697 If unset, or if set to a null QRectF, sceneRect() will return the largest-
1698 bounding rect of all items on the scene since the scene was created (i.e.,-
1699 a rectangle that grows when items are added to or moved in the scene, but-
1700 never shrinks).-
1701-
1702 \sa width(), height(), QGraphicsView::sceneRect-
1703*/-
1704QRectF QGraphicsScene::sceneRect() const-
1705{-
1706 Q_D(const QGraphicsScene);-
1707 if (d->hasSceneRect)
d->hasSceneRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1708 return d->sceneRect;
never executed: return d->sceneRect;
0
1709-
1710 if (d->dirtyGrowingItemsBoundingRect) {
d->dirtyGrowin...msBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1711 // Lazily update the growing items bounding rect-
1712 QGraphicsScenePrivate *thatd = const_cast<QGraphicsScenePrivate *>(d);-
1713 QRectF oldGrowingBoundingRect = thatd->growingItemsBoundingRect;-
1714 thatd->growingItemsBoundingRect |= itemsBoundingRect();-
1715 thatd->dirtyGrowingItemsBoundingRect = false;-
1716 if (oldGrowingBoundingRect != thatd->growingItemsBoundingRect)
oldGrowingBoun...msBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1717 emit const_cast<QGraphicsScene *>(this)->sceneRectChanged(thatd->growingItemsBoundingRect);
never executed: const_cast<QGraphicsScene *>(this)->sceneRectChanged(thatd->growingItemsBoundingRect);
0
1718 }
never executed: end of block
0
1719 return d->growingItemsBoundingRect;
never executed: return d->growingItemsBoundingRect;
0
1720}-
1721void QGraphicsScene::setSceneRect(const QRectF &rect)-
1722{-
1723 Q_D(QGraphicsScene);-
1724 if (rect != d->sceneRect) {
rect != d->sceneRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1725 d->hasSceneRect = !rect.isNull();-
1726 d->sceneRect = rect;-
1727 emit sceneRectChanged(d->hasSceneRect ? rect : d->growingItemsBoundingRect);-
1728 }
never executed: end of block
0
1729}
never executed: end of block
0
1730-
1731/*!-
1732 \fn qreal QGraphicsScene::width() const-
1733-
1734 This convenience function is equivalent to calling sceneRect().width().-
1735-
1736 \sa height()-
1737*/-
1738-
1739/*!-
1740 \fn qreal QGraphicsScene::height() const-
1741-
1742 This convenience function is equivalent to calling \c sceneRect().height().-
1743-
1744 \sa width()-
1745*/-
1746-
1747/*!-
1748 Renders the \a source rect from scene into \a target, using \a painter. This-
1749 function is useful for capturing the contents of the scene onto a paint-
1750 device, such as a QImage (e.g., to take a screenshot), or for printing-
1751 with QPrinter. For example:-
1752-
1753 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 1-
1754-
1755 If \a source is a null rect, this function will use sceneRect() to-
1756 determine what to render. If \a target is a null rect, the dimensions of \a-
1757 painter's paint device will be used.-
1758-
1759 The source rect contents will be transformed according to \a-
1760 aspectRatioMode to fit into the target rect. By default, the aspect ratio-
1761 is kept, and \a source is scaled to fit in \a target.-
1762-
1763 \sa QGraphicsView::render()-
1764*/-
1765void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRectF &source,-
1766 Qt::AspectRatioMode aspectRatioMode)-
1767{-
1768 // ### Switch to using the recursive rendering algorithm instead.-
1769-
1770 // Default source rect = scene rect-
1771 QRectF sourceRect = source;-
1772 if (sourceRect.isNull())
sourceRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1773 sourceRect = sceneRect();
never executed: sourceRect = sceneRect();
0
1774-
1775 // Default target rect = device rect-
1776 QRectF targetRect = target;-
1777 if (targetRect.isNull()) {
targetRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1778 if (painter->device()->devType() == QInternal::Picture)
painter->devic...ernal::PictureDescription
TRUEnever evaluated
FALSEnever evaluated
0
1779 targetRect = sourceRect;
never executed: targetRect = sourceRect;
0
1780 else-
1781 targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
never executed: targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
0
1782 }-
1783-
1784 // Find the ideal x / y scaling ratio to fit \a source into \a target.-
1785 qreal xratio = targetRect.width() / sourceRect.width();-
1786 qreal yratio = targetRect.height() / sourceRect.height();-
1787-
1788 // Scale according to the aspect ratio mode.-
1789 switch (aspectRatioMode) {-
1790 case Qt::KeepAspectRatio:
never executed: case Qt::KeepAspectRatio:
0
1791 xratio = yratio = qMin(xratio, yratio);-
1792 break;
never executed: break;
0
1793 case Qt::KeepAspectRatioByExpanding:
never executed: case Qt::KeepAspectRatioByExpanding:
0
1794 xratio = yratio = qMax(xratio, yratio);-
1795 break;
never executed: break;
0
1796 case Qt::IgnoreAspectRatio:
never executed: case Qt::IgnoreAspectRatio:
0
1797 break;
never executed: break;
0
1798 }-
1799-
1800 // Find all items to draw, and reverse the list (we want to draw-
1801 // in reverse order).-
1802 QList<QGraphicsItem *> itemList = items(sourceRect, Qt::IntersectsItemBoundingRect);-
1803 QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()];-
1804 int numItems = itemList.size();-
1805 for (int i = 0; i < numItems; ++i)
i < numItemsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1806 itemArray[numItems - i - 1] = itemList.at(i);
never executed: itemArray[numItems - i - 1] = itemList.at(i);
0
1807 itemList.clear();-
1808-
1809 painter->save();-
1810-
1811 // Transform the painter.-
1812 painter->setClipRect(targetRect, Qt::IntersectClip);-
1813 QTransform painterTransform;-
1814 painterTransform *= QTransform()-
1815 .translate(targetRect.left(), targetRect.top())-
1816 .scale(xratio, yratio)-
1817 .translate(-sourceRect.left(), -sourceRect.top());-
1818 painter->setWorldTransform(painterTransform, true);-
1819-
1820 // Generate the style options-
1821 QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems];-
1822 for (int i = 0; i < numItems; ++i)
i < numItemsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1823 itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect());
never executed: itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect());
0
1824-
1825 // Render the scene.-
1826 drawBackground(painter, sourceRect);-
1827 drawItems(painter, numItems, itemArray, styleOptionArray);-
1828 drawForeground(painter, sourceRect);-
1829-
1830 delete [] itemArray;-
1831 delete [] styleOptionArray;-
1832-
1833 painter->restore();-
1834}
never executed: end of block
0
1835-
1836/*!-
1837 \property QGraphicsScene::itemIndexMethod-
1838 \brief the item indexing method.-
1839-
1840 QGraphicsScene applies an indexing algorithm to the scene, to speed up-
1841 item discovery functions like items() and itemAt(). Indexing is most-
1842 efficient for static scenes (i.e., where items don't move around). For-
1843 dynamic scenes, or scenes with many animated items, the index bookkeeping-
1844 can outweight the fast lookup speeds.-
1845-
1846 For the common case, the default index method BspTreeIndex works fine. If-
1847 your scene uses many animations and you are experiencing slowness, you can-
1848 disable indexing by calling \c setItemIndexMethod(NoIndex).-
1849-
1850 \sa bspTreeDepth-
1851*/-
1852QGraphicsScene::ItemIndexMethod QGraphicsScene::itemIndexMethod() const-
1853{-
1854 Q_D(const QGraphicsScene);-
1855 return d->indexMethod;
never executed: return d->indexMethod;
0
1856}-
1857void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method)-
1858{-
1859 Q_D(QGraphicsScene);-
1860 if (d->indexMethod == method)
d->indexMethod == methodDescription
TRUEnever evaluated
FALSEnever evaluated
0
1861 return;
never executed: return;
0
1862-
1863 d->indexMethod = method;-
1864-
1865 QList<QGraphicsItem *> oldItems = d->index->items(Qt::DescendingOrder);-
1866 delete d->index;-
1867 if (method == BspTreeIndex)
method == BspTreeIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1868 d->index = new QGraphicsSceneBspTreeIndex(this);
never executed: d->index = new QGraphicsSceneBspTreeIndex(this);
0
1869 else-
1870 d->index = new QGraphicsSceneLinearIndex(this);
never executed: d->index = new QGraphicsSceneLinearIndex(this);
0
1871 for (int i = oldItems.size() - 1; i >= 0; --i)
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1872 d->index->addItem(oldItems.at(i));
never executed: d->index->addItem(oldItems.at(i));
0
1873}
never executed: end of block
0
1874-
1875/*!-
1876 \property QGraphicsScene::bspTreeDepth-
1877 \brief the depth of QGraphicsScene's BSP index tree-
1878 \since 4.3-
1879-
1880 This property has no effect when NoIndex is used.-
1881-
1882 This value determines the depth of QGraphicsScene's BSP tree. The depth-
1883 directly affects QGraphicsScene's performance and memory usage; the latter-
1884 growing exponentially with the depth of the tree. With an optimal tree-
1885 depth, QGraphicsScene can instantly determine the locality of items, even-
1886 for scenes with thousands or millions of items. This also greatly improves-
1887 rendering performance.-
1888-
1889 By default, the value is 0, in which case Qt will guess a reasonable-
1890 default depth based on the size, location and number of items in the-
1891 scene. If these parameters change frequently, however, you may experience-
1892 slowdowns as QGraphicsScene retunes the depth internally. You can avoid-
1893 potential slowdowns by fixating the tree depth through setting this-
1894 property.-
1895-
1896 The depth of the tree and the size of the scene rectangle decide the-
1897 granularity of the scene's partitioning. The size of each scene segment is-
1898 determined by the following algorithm:-
1899-
1900 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 2-
1901-
1902 The BSP tree has an optimal size when each segment contains between 0 and-
1903 10 items.-
1904-
1905 \sa itemIndexMethod-
1906*/-
1907int QGraphicsScene::bspTreeDepth() const-
1908{-
1909 Q_D(const QGraphicsScene);-
1910 QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);-
1911 return bspTree ? bspTree->bspTreeDepth() : 0;
never executed: return bspTree ? bspTree->bspTreeDepth() : 0;
0
1912}-
1913void QGraphicsScene::setBspTreeDepth(int depth)-
1914{-
1915 Q_D(QGraphicsScene);-
1916 if (depth < 0) {
depth < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1917 qWarning("QGraphicsScene::setBspTreeDepth: invalid depth %d ignored; must be >= 0", depth);-
1918 return;
never executed: return;
0
1919 }-
1920-
1921 QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);-
1922 if (!bspTree) {
!bspTreeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1923 qWarning("QGraphicsScene::setBspTreeDepth: can not apply if indexing method is not BSP");-
1924 return;
never executed: return;
0
1925 }-
1926 bspTree->setBspTreeDepth(depth);-
1927}
never executed: end of block
0
1928-
1929/*!-
1930 \property QGraphicsScene::sortCacheEnabled-
1931 \brief whether sort caching is enabled-
1932 \since 4.5-
1933 \obsolete-
1934-
1935 Since Qt 4.6, this property has no effect.-
1936*/-
1937bool QGraphicsScene::isSortCacheEnabled() const-
1938{-
1939 Q_D(const QGraphicsScene);-
1940 return d->sortCacheEnabled;
never executed: return d->sortCacheEnabled;
0
1941}-
1942void QGraphicsScene::setSortCacheEnabled(bool enabled)-
1943{-
1944 Q_D(QGraphicsScene);-
1945 if (d->sortCacheEnabled == enabled)
d->sortCacheEnabled == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1946 return;
never executed: return;
0
1947 d->sortCacheEnabled = enabled;-
1948}
never executed: end of block
0
1949-
1950/*!-
1951 Calculates and returns the bounding rect of all items on the scene. This-
1952 function works by iterating over all items, and because of this, it can-
1953 be slow for large scenes.-
1954-
1955 \sa sceneRect()-
1956*/-
1957QRectF QGraphicsScene::itemsBoundingRect() const-
1958{-
1959 // Does not take untransformable items into account.-
1960 QRectF boundingRect;-
1961 const auto items_ = items();-
1962 for (QGraphicsItem *item : items_)-
1963 boundingRect |= item->sceneBoundingRect();
never executed: boundingRect |= item->sceneBoundingRect();
0
1964 return boundingRect;
never executed: return boundingRect;
0
1965}-
1966-
1967/*!-
1968 Returns an ordered list of all items on the scene. \a order decides the-
1969 stacking order.-
1970-
1971 \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting}-
1972*/-
1973QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const-
1974{-
1975 Q_D(const QGraphicsScene);-
1976 return d->index->items(order);
never executed: return d->index->items(order);
0
1977}-
1978-
1979/*!-
1980 \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const-
1981 \obsolete-
1982 \since 4.3-
1983-
1984 This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode).-
1985-
1986 This function is deprecated and returns incorrect results if the scene-
1987 contains items that ignore transformations. Use the overload that takes-
1988 a QTransform instead.-
1989*/-
1990-
1991/*!-
1992 \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const-
1993 \overload-
1994 \since 4.6-
1995-
1996 \brief Returns all visible items that, depending on \a mode, are-
1997 either inside or intersect with the rectangle defined by \a x, \a y,-
1998 \a w and \a h, in a list sorted using \a order. In this case, "visible" defines items for which:-
1999 isVisible() returns \c true, effectiveOpacity() returns a value greater than 0.0-
2000 (which is fully transparent) and the parent item does not clip it.-
2001-
2002 \a deviceTransform is the transformation that applies to the view, and needs to-
2003 be provided if the scene contains items that ignore transformations.-
2004*/-
2005-
2006/*!-
2007 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const-
2008 \since 4.6-
2009-
2010 \brief Returns all visible items that, depending on \a mode, are at-
2011 the specified \a pos in a list sorted using \a order. In this case, "visible" defines items for which:-
2012 isVisible() returns \c true, effectiveOpacity() returns a value greater than 0.0-
2013 (which is fully transparent) and the parent item does not clip it.-
2014-
2015 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
2016 exact shape intersects with \a pos are returned.-
2017-
2018 \a deviceTransform is the transformation that applies to the view, and needs to-
2019 be provided if the scene contains items that ignore transformations.-
2020-
2021 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}-
2022*/-
2023QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode,-
2024 Qt::SortOrder order, const QTransform &deviceTransform) const-
2025{-
2026 Q_D(const QGraphicsScene);-
2027 return d->index->items(pos, mode, order, deviceTransform);
never executed: return d->index->items(pos, mode, order, deviceTransform);
0
2028}-
2029-
2030/*!-
2031 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const-
2032 \overload-
2033 \since 4.6-
2034-
2035 \brief Returns all visible items that, depending on \a mode, are-
2036 either inside or intersect with the specified \a rect, in a-
2037 list sorted using \a order. In this case, "visible" defines items for which:-
2038 isVisible() returns \c true, effectiveOpacity() returns a value greater than 0.0-
2039 (which is fully transparent) and the parent item does not clip it.-
2040-
2041 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
2042 exact shape intersects with or is contained by \a rect are returned.-
2043-
2044 \a deviceTransform is the transformation that applies to the view, and needs to-
2045 be provided if the scene contains items that ignore transformations.-
2046-
2047 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}-
2048*/-
2049QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode,-
2050 Qt::SortOrder order, const QTransform &deviceTransform) const-
2051{-
2052 Q_D(const QGraphicsScene);-
2053 return d->index->items(rect, mode, order, deviceTransform);
never executed: return d->index->items(rect, mode, order, deviceTransform);
0
2054}-
2055-
2056/*!-
2057 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const-
2058 \overload-
2059 \since 4.6-
2060-
2061 \brief Returns all visible items that, depending on \a mode, are-
2062 either inside or intersect with the specified \a polygon, in-
2063 a list sorted using \a order. In this case, "visible" defines items for which:-
2064 isVisible() returns \c true, effectiveOpacity() returns a value greater than 0.0-
2065 (which is fully transparent) and the parent item does not clip it.-
2066-
2067 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
2068 exact shape intersects with or is contained by \a polygon are returned.-
2069-
2070 \a deviceTransform is the transformation that applies to the view, and needs to-
2071 be provided if the scene contains items that ignore transformations.-
2072-
2073 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}-
2074*/-
2075QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode,-
2076 Qt::SortOrder order, const QTransform &deviceTransform) const-
2077{-
2078 Q_D(const QGraphicsScene);-
2079 return d->index->items(polygon, mode, order, deviceTransform);
never executed: return d->index->items(polygon, mode, order, deviceTransform);
0
2080}-
2081-
2082/*!-
2083 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const-
2084 \overload-
2085 \since 4.6-
2086-
2087 \brief Returns all visible items that, depending on \a mode, are-
2088 either inside or intersect with the specified \a path, in a-
2089 list sorted using \a order. In this case, "visible" defines items for which:-
2090 isVisible() returns \c true, effectiveOpacity() returns a value greater than 0.0-
2091 (which is fully transparent) and the parent item does not clip it.-
2092-
2093 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
2094 exact shape intersects with or is contained by \a path are returned.-
2095-
2096 \a deviceTransform is the transformation that applies to the view, and needs to-
2097 be provided if the scene contains items that ignore transformations.-
2098-
2099 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}-
2100*/-
2101QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode,-
2102 Qt::SortOrder order, const QTransform &deviceTransform) const-
2103{-
2104 Q_D(const QGraphicsScene);-
2105 return d->index->items(path, mode, order, deviceTransform);
never executed: return d->index->items(path, mode, order, deviceTransform);
0
2106}-
2107-
2108/*!-
2109 Returns a list of all items that collide with \a item. Collisions are-
2110 determined by calling QGraphicsItem::collidesWithItem(); the collision-
2111 detection is determined by \a mode. By default, all items whose shape-
2112 intersects \a item or is contained inside \a item's shape are returned.-
2113-
2114 The items are returned in descending stacking order (i.e., the first item-
2115 in the list is the uppermost item, and the last item is the lowermost-
2116 item).-
2117-
2118 \sa items(), itemAt(), QGraphicsItem::collidesWithItem(), {QGraphicsItem#Sorting}{Sorting}-
2119*/-
2120QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item,-
2121 Qt::ItemSelectionMode mode) const-
2122{-
2123 Q_D(const QGraphicsScene);-
2124 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2125 qWarning("QGraphicsScene::collidingItems: cannot find collisions for null item");-
2126 return QList<QGraphicsItem *>();
never executed: return QList<QGraphicsItem *>();
0
2127 }-
2128-
2129 // Does not support ItemIgnoresTransformations.-
2130 QList<QGraphicsItem *> tmp;-
2131 const auto itemsInVicinity = d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder);-
2132 for (QGraphicsItem *itemInVicinity : itemsInVicinity) {-
2133 if (item != itemInVicinity && item->collidesWithItem(itemInVicinity, mode))
item != itemInVicinityDescription
TRUEnever evaluated
FALSEnever evaluated
item->collides...icinity, mode)Description
TRUEnever evaluated
FALSEnever evaluated
0
2134 tmp << itemInVicinity;
never executed: tmp << itemInVicinity;
0
2135 }
never executed: end of block
0
2136 return tmp;
never executed: return tmp;
0
2137}-
2138-
2139/*!-
2140 \fn QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const-
2141 \overload-
2142 \obsolete-
2143-
2144 Returns the topmost visible item at the specified \a position, or 0 if-
2145 there are no items at this position.-
2146-
2147 This function is deprecated and returns incorrect results if the scene-
2148 contains items that ignore transformations. Use the overload that takes-
2149 a QTransform instead.-
2150-
2151 Note: See items() for a definition of which items are considered visible by this function.-
2152-
2153 \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting}-
2154*/-
2155-
2156/*!-
2157 \since 4.6-
2158-
2159 Returns the topmost visible item at the specified \a position, or 0-
2160 if there are no items at this position.-
2161-
2162 \a deviceTransform is the transformation that applies to the view, and needs to-
2163 be provided if the scene contains items that ignore transformations.-
2164-
2165 Note: See items() for a definition of which items are considered visible by this function.-
2166-
2167 \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting}-
2168*/-
2169QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const-
2170{-
2171 const QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,-
2172 Qt::DescendingOrder, deviceTransform);-
2173 return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
never executed: return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
0
2174}-
2175-
2176/*!-
2177 \fn QGraphicsScene::itemAt(qreal x, qreal y, const QTransform &deviceTransform) const-
2178 \overload-
2179 \since 4.6-
2180-
2181 Returns the topmost visible item at the position specified by (\a x, \a-
2182 y), or 0 if there are no items at this position.-
2183-
2184 \a deviceTransform is the transformation that applies to the view, and needs to-
2185 be provided if the scene contains items that ignore transformations.-
2186-
2187 This convenience function is equivalent to calling \c-
2188 {itemAt(QPointF(x, y), deviceTransform)}.-
2189-
2190 Note: See items() for a definition of which items are considered visible by this function.-
2191*/-
2192-
2193/*!-
2194 \fn QGraphicsScene::itemAt(qreal x, qreal y) const-
2195 \overload-
2196 \obsolete-
2197-
2198 Returns the topmost visible item at the position specified by (\a x, \a-
2199 y), or 0 if there are no items at this position.-
2200-
2201 This convenience function is equivalent to calling \c-
2202 {itemAt(QPointF(x, y))}.-
2203-
2204 This function is deprecated and returns incorrect results if the scene-
2205 contains items that ignore transformations. Use the overload that takes-
2206 a QTransform instead.-
2207-
2208 Note: See items() for a definition of which items are considered visible by this function.-
2209*/-
2210-
2211/*!-
2212 Returns a list of all currently selected items. The items are-
2213 returned in no particular order.-
2214-
2215 \sa setSelectionArea()-
2216*/-
2217QList<QGraphicsItem *> QGraphicsScene::selectedItems() const-
2218{-
2219 Q_D(const QGraphicsScene);-
2220-
2221 // Optimization: Lazily removes items that are not selected.-
2222 QGraphicsScene *that = const_cast<QGraphicsScene *>(this);-
2223 QSet<QGraphicsItem *> actuallySelectedSet;-
2224 foreach (QGraphicsItem *item, that->d_func()->selectedItems) {-
2225 if (item->isSelected())
item->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
2226 actuallySelectedSet << item;
never executed: actuallySelectedSet << item;
0
2227 }
never executed: end of block
0
2228-
2229 that->d_func()->selectedItems = actuallySelectedSet;-
2230-
2231 return d->selectedItems.values();
never executed: return d->selectedItems.values();
0
2232}-
2233-
2234/*!-
2235 Returns the selection area that was previously set with-
2236 setSelectionArea(), or an empty QPainterPath if no selection area has been-
2237 set.-
2238-
2239 \sa setSelectionArea()-
2240*/-
2241QPainterPath QGraphicsScene::selectionArea() const-
2242{-
2243 Q_D(const QGraphicsScene);-
2244 return d->selectionArea;
never executed: return d->selectionArea;
0
2245}-
2246-
2247/*!-
2248 \since 4.6-
2249-
2250 Sets the selection area to \a path. All items within this area are-
2251 immediately selected, and all items outside are unselected. You can get-
2252 the list of all selected items by calling selectedItems().-
2253-
2254 \a deviceTransform is the transformation that applies to the view, and needs to-
2255 be provided if the scene contains items that ignore transformations.-
2256-
2257 For an item to be selected, it must be marked as \e selectable-
2258 (QGraphicsItem::ItemIsSelectable).-
2259-
2260 \sa clearSelection(), selectionArea()-
2261*/-
2262void QGraphicsScene::setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform)-
2263{-
2264 setSelectionArea(path, Qt::IntersectsItemShape, deviceTransform);-
2265}
never executed: end of block
0
2266-
2267/*!-
2268 \overload-
2269 \since 4.6-
2270-
2271 Sets the selection area to \a path using \a mode to determine if items are-
2272 included in the selection area.-
2273-
2274 \a deviceTransform is the transformation that applies to the view, and needs to-
2275 be provided if the scene contains items that ignore transformations.-
2276-
2277 \sa clearSelection(), selectionArea()-
2278*/-
2279void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode,-
2280 const QTransform &deviceTransform)-
2281{-
2282 setSelectionArea(path, Qt::ReplaceSelection, mode, deviceTransform);-
2283}
never executed: end of block
0
2284-
2285/*!-
2286 \overload-
2287 \since 5.5-
2288-
2289 Sets the selection area to \a path using \a mode to determine if items are-
2290 included in the selection area.-
2291-
2292 \a deviceTransform is the transformation that applies to the view, and needs to-
2293 be provided if the scene contains items that ignore transformations.-
2294-
2295 \a selectionOperation determines what to do with the currently selected items.-
2296-
2297 \sa clearSelection(), selectionArea()-
2298*/-
2299void QGraphicsScene::setSelectionArea(const QPainterPath &path,-
2300 Qt::ItemSelectionOperation selectionOperation,-
2301 Qt::ItemSelectionMode mode,-
2302 const QTransform &deviceTransform)-
2303{-
2304 Q_D(QGraphicsScene);-
2305-
2306 // Note: with boolean path operations, we can improve performance here-
2307 // quite a lot by "growing" the old path instead of replacing it. That-
2308 // allows us to only check the intersect area for changes, instead of-
2309 // reevaluating the whole path over again.-
2310 d->selectionArea = path;-
2311-
2312 QSet<QGraphicsItem *> unselectItems = d->selectedItems;-
2313-
2314 // Disable emitting selectionChanged() for individual items.-
2315 ++d->selectionChanging;-
2316 bool changed = false;-
2317-
2318 // Set all items in path to selected.-
2319 const auto items = this->items(path, mode, Qt::DescendingOrder, deviceTransform);-
2320 for (QGraphicsItem *item : items) {-
2321 if (item->flags() & QGraphicsItem::ItemIsSelectable) {
item->flags() ...emIsSelectableDescription
TRUEnever evaluated
FALSEnever evaluated
0
2322 if (!item->isSelected())
!item->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
2323 changed = true;
never executed: changed = true;
0
2324 unselectItems.remove(item);-
2325 item->setSelected(true);-
2326 }
never executed: end of block
0
2327 }
never executed: end of block
0
2328-
2329 switch (selectionOperation) {-
2330 case Qt::ReplaceSelection:
never executed: case Qt::ReplaceSelection:
0
2331 // Deselect all items outside path.-
2332 foreach (QGraphicsItem *item, unselectItems) {-
2333 item->setSelected(false);-
2334 changed = true;-
2335 }
never executed: end of block
0
2336 break;
never executed: break;
0
2337 default:
never executed: default:
0
2338 break;
never executed: break;
0
2339 }-
2340-
2341 // Reenable emitting selectionChanged() for individual items.-
2342 --d->selectionChanging;-
2343-
2344 if (!d->selectionChanging && changed)
!d->selectionChangingDescription
TRUEnever evaluated
FALSEnever evaluated
changedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2345 emit selectionChanged();
never executed: selectionChanged();
0
2346}
never executed: end of block
0
2347-
2348/*!-
2349 Clears the current selection.-
2350-
2351 \sa setSelectionArea(), selectedItems()-
2352*/-
2353void QGraphicsScene::clearSelection()-
2354{-
2355 Q_D(QGraphicsScene);-
2356-
2357 // Disable emitting selectionChanged-
2358 ++d->selectionChanging;-
2359 bool changed = !d->selectedItems.isEmpty();-
2360-
2361 foreach (QGraphicsItem *item, d->selectedItems)-
2362 item->setSelected(false);
never executed: item->setSelected(false);
0
2363 d->selectedItems.clear();-
2364-
2365 // Reenable emitting selectionChanged() for individual items.-
2366 --d->selectionChanging;-
2367-
2368 if (!d->selectionChanging && changed)
!d->selectionChangingDescription
TRUEnever evaluated
FALSEnever evaluated
changedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2369 emit selectionChanged();
never executed: selectionChanged();
0
2370}
never executed: end of block
0
2371-
2372/*!-
2373 \since 4.4-
2374-
2375 Removes and deletes all items from the scene, but otherwise leaves the-
2376 state of the scene unchanged.-
2377-
2378 \sa addItem()-
2379*/-
2380void QGraphicsScene::clear()-
2381{-
2382 Q_D(QGraphicsScene);-
2383 // NB! We have to clear the index before deleting items; otherwise the-
2384 // index might try to access dangling item pointers.-
2385 d->index->clear();-
2386 // NB! QGraphicsScenePrivate::unregisterTopLevelItem() removes items-
2387 while (!d->topLevelItems.isEmpty())
!d->topLevelItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2388 delete d->topLevelItems.first();
never executed: delete d->topLevelItems.first();
0
2389 Q_ASSERT(d->topLevelItems.isEmpty());-
2390 d->lastItemCount = 0;-
2391 d->allItemsIgnoreHoverEvents = true;-
2392 d->allItemsUseDefaultCursor = true;-
2393 d->allItemsIgnoreTouchEvents = true;-
2394}
never executed: end of block
0
2395-
2396/*!-
2397 Groups all items in \a items into a new QGraphicsItemGroup, and returns a-
2398 pointer to the group. The group is created with the common ancestor of \a-
2399 items as its parent, and with position (0, 0). The items are all-
2400 reparented to the group, and their positions and transformations are-
2401 mapped to the group. If \a items is empty, this function will return an-
2402 empty top-level QGraphicsItemGroup.-
2403-
2404 QGraphicsScene has ownership of the group item; you do not need to delete-
2405 it. To dismantle (ungroup) a group, call destroyItemGroup().-
2406-
2407 \sa destroyItemGroup(), QGraphicsItemGroup::addToGroup()-
2408*/-
2409QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *> &items)-
2410{-
2411 // Build a list of the first item's ancestors-
2412 QList<QGraphicsItem *> ancestors;-
2413 int n = 0;-
2414 if (!items.isEmpty()) {
!items.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2415 QGraphicsItem *parent = items.at(n++);-
2416 while ((parent = parent->parentItem()))
(parent = pare...>parentItem())Description
TRUEnever evaluated
FALSEnever evaluated
0
2417 ancestors.append(parent);
never executed: ancestors.append(parent);
0
2418 }
never executed: end of block
0
2419-
2420 // Find the common ancestor for all items-
2421 QGraphicsItem *commonAncestor = 0;-
2422 if (!ancestors.isEmpty()) {
!ancestors.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2423 while (n < items.size()) {
n < items.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2424 int commonIndex = -1;-
2425 QGraphicsItem *parent = items.at(n++);-
2426 do {-
2427 int index = ancestors.indexOf(parent, qMax(0, commonIndex));-
2428 if (index != -1) {
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2429 commonIndex = index;-
2430 break;
never executed: break;
0
2431 }-
2432 } while ((parent = parent->parentItem()));
never executed: end of block
(parent = pare...>parentItem())Description
TRUEnever evaluated
FALSEnever evaluated
0
2433-
2434 if (commonIndex == -1) {
commonIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2435 commonAncestor = 0;-
2436 break;
never executed: break;
0
2437 }-
2438-
2439 commonAncestor = ancestors.at(commonIndex);-
2440 }
never executed: end of block
0
2441 }
never executed: end of block
0
2442-
2443 // Create a new group at that level-
2444 QGraphicsItemGroup *group = new QGraphicsItemGroup(commonAncestor);-
2445 if (!commonAncestor)
!commonAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2446 addItem(group);
never executed: addItem(group);
0
2447 for (QGraphicsItem *item : items)-
2448 group->addToGroup(item);
never executed: group->addToGroup(item);
0
2449 return group;
never executed: return group;
0
2450}-
2451-
2452/*!-
2453 Reparents all items in \a group to \a group's parent item, then removes \a-
2454 group from the scene, and finally deletes it. The items' positions and-
2455 transformations are mapped from the group to the group's parent.-
2456-
2457 \sa createItemGroup(), QGraphicsItemGroup::removeFromGroup()-
2458*/-
2459void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group)-
2460{-
2461 const auto items = group->childItems();-
2462 for (QGraphicsItem *item : items)-
2463 group->removeFromGroup(item);
never executed: group->removeFromGroup(item);
0
2464 removeItem(group);-
2465 delete group;-
2466}
never executed: end of block
0
2467-
2468/*!-
2469 Adds or moves the \a item and all its childen to this scene.-
2470 This scene takes ownership of the \a item.-
2471-
2472 If the item is visible (i.e., QGraphicsItem::isVisible() returns-
2473 true), QGraphicsScene will emit changed() once control goes back-
2474 to the event loop.-
2475-
2476 If the item is already in a different scene, it will first be-
2477 removed from its old scene, and then added to this scene as a-
2478 top-level.-
2479-
2480 QGraphicsScene will send ItemSceneChange notifications to \a item-
2481 while it is added to the scene. If item does not currently belong-
2482 to a scene, only one notification is sent. If it does belong to-
2483 scene already (i.e., it is moved to this scene), QGraphicsScene-
2484 will send an addition notification as the item is removed from its-
2485 previous scene.-
2486-
2487 If the item is a panel, the scene is active, and there is no-
2488 active panel in the scene, then the item will be activated.-
2489-
2490 \sa removeItem(), addEllipse(), addLine(), addPath(), addPixmap(),-
2491 addRect(), addText(), addWidget(), {QGraphicsItem#Sorting}{Sorting}-
2492*/-
2493void QGraphicsScene::addItem(QGraphicsItem *item)-
2494{-
2495 Q_D(QGraphicsScene);-
2496 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2497 qWarning("QGraphicsScene::addItem: cannot add null item");-
2498 return;
never executed: return;
0
2499 }-
2500 if (item->d_ptr->scene == this) {
item->d_ptr->scene == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2501 qWarning("QGraphicsScene::addItem: item has already been added to this scene");-
2502 return;
never executed: return;
0
2503 }-
2504 // Remove this item from its existing scene-
2505 if (QGraphicsScene *oldScene = item->d_ptr->scene)
QGraphicsScene...->d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2506 oldScene->removeItem(item);
never executed: oldScene->removeItem(item);
0
2507-
2508 // Notify the item that its scene is changing, and allow the item to-
2509 // react.-
2510 const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,-
2511 QVariant::fromValue<QGraphicsScene *>(this)));-
2512 QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);-
2513 if (targetScene != this) {
targetScene != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2514 if (targetScene && item->d_ptr->scene != targetScene)
targetSceneDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->s...!= targetSceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2515 targetScene->addItem(item);
never executed: targetScene->addItem(item);
0
2516 return;
never executed: return;
0
2517 }-
2518-
2519 // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete-
2520 // function allows far more opportunity for delayed-construction optimization.-
2521 if (!item->d_ptr->isDeclarativeItem) {
!item->d_ptr->...eclarativeItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2522 if (d->unpolishedItems.isEmpty()) {
d->unpolishedItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2523 QMetaMethod method = metaObject()->method(d->polishItemsIndex);-
2524 method.invoke(this, Qt::QueuedConnection);-
2525 }
never executed: end of block
0
2526 d->unpolishedItems.append(item);-
2527 item->d_ptr->pendingPolish = true;-
2528 }
never executed: end of block
0
2529-
2530 // Detach this item from its parent if the parent's scene is different-
2531 // from this scene.-
2532 if (QGraphicsItem *itemParent = item->d_ptr->parent) {
QGraphicsItem ...>d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2533 if (itemParent->d_ptr->scene != this)
itemParent->d_...>scene != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2534 item->setParentItem(0);
never executed: item->setParentItem(0);
0
2535 }
never executed: end of block
0
2536-
2537 // Add the item to this scene-
2538 item->d_func()->scene = targetScene;-
2539-
2540 // Add the item in the index-
2541 d->index->addItem(item);-
2542-
2543 // Add to list of toplevels if this item is a toplevel.-
2544 if (!item->d_ptr->parent)
!item->d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2545 d->registerTopLevelItem(item);
never executed: d->registerTopLevelItem(item);
0
2546-
2547 // Add to list of items that require an update. We cannot assume that the-
2548 // item is fully constructed, so calling item->update() can lead to a pure-
2549 // virtual function call to boundingRect().-
2550 d->markDirty(item);-
2551 d->dirtyGrowingItemsBoundingRect = true;-
2552-
2553 // Disable selectionChanged() for individual items-
2554 ++d->selectionChanging;-
2555 int oldSelectedItemSize = d->selectedItems.size();-
2556-
2557 // Enable mouse tracking if the item accepts hover events or has a cursor set.-
2558 if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) {
d->allItemsIgnoreHoverEventsDescription
TRUEnever evaluated
FALSEnever evaluated
d->itemAccepts...s_helper(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
2559 d->allItemsIgnoreHoverEvents = false;-
2560 d->enableMouseTrackingOnViews();-
2561 }
never executed: end of block
0
2562#ifndef QT_NO_CURSOR-
2563 if (d->allItemsUseDefaultCursor && item->d_ptr->hasCursor) {
d->allItemsUseDefaultCursorDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2564 d->allItemsUseDefaultCursor = false;-
2565 if (d->allItemsIgnoreHoverEvents) // already enabled otherwise
d->allItemsIgnoreHoverEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2566 d->enableMouseTrackingOnViews();
never executed: d->enableMouseTrackingOnViews();
0
2567 }
never executed: end of block
0
2568#endif //QT_NO_CURSOR-
2569-
2570 // Enable touch events if the item accepts touch events.-
2571 if (d->allItemsIgnoreTouchEvents && item->d_ptr->acceptTouchEvents) {
d->allItemsIgnoreTouchEventsDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->acceptTouchEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2572 d->allItemsIgnoreTouchEvents = false;-
2573 d->enableTouchEventsOnViews();-
2574 }
never executed: end of block
0
2575-
2576#ifndef QT_NO_GESTURES-
2577 const auto gestures = item->d_ptr->gestureContext.keys(); // FIXME: iterate over hash directly?-
2578 for (Qt::GestureType gesture : gestures)-
2579 d->grabGesture(item, gesture);
never executed: d->grabGesture(item, gesture);
0
2580#endif-
2581-
2582 // Update selection lists-
2583 if (item->isSelected())
item->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
2584 d->selectedItems << item;
never executed: d->selectedItems << item;
0
2585 if (item->isWidget() && item->isVisible() && static_cast<QGraphicsWidget *>(item)->windowType() == Qt::Popup)
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
static_cast<QG...) == Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
2586 d->addPopup(static_cast<QGraphicsWidget *>(item));
never executed: d->addPopup(static_cast<QGraphicsWidget *>(item));
0
2587 if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
item->panelMod...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2588 d->enterModal(item);
never executed: d->enterModal(item);
0
2589-
2590 // Update creation order focus chain. Make sure to leave the widget's-
2591 // internal tab order intact.-
2592 if (item->isWidget()) {
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
2593 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);-
2594 if (!d->tabFocusFirst) {
!d->tabFocusFirstDescription
TRUEnever evaluated
FALSEnever evaluated
0
2595 // No first tab focus widget - make this the first tab focus-
2596 // widget.-
2597 d->tabFocusFirst = widget;-
2598 } else if (!widget->parentWidget() && !widget->isPanel()) {
never executed: end of block
!widget->parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
!widget->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2599 // Adding a widget that is not part of a tab focus chain.-
2600 QGraphicsWidget *myNewPrev = d->tabFocusFirst->d_func()->focusPrev;-
2601 myNewPrev->d_func()->focusNext = widget;-
2602 widget->d_func()->focusPrev->d_func()->focusNext = d->tabFocusFirst;-
2603 d->tabFocusFirst->d_func()->focusPrev = widget->d_func()->focusPrev;-
2604 widget->d_func()->focusPrev = myNewPrev;-
2605 }
never executed: end of block
0
2606 }
never executed: end of block
0
2607-
2608 // Add all children recursively-
2609 item->d_ptr->ensureSortedChildren();-
2610 for (int i = 0; i < item->d_ptr->children.size(); ++i)
i < item->d_pt...hildren.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
2611 addItem(item->d_ptr->children.at(i));
never executed: addItem(item->d_ptr->children.at(i));
0
2612-
2613 // Resolve font and palette.-
2614 item->d_ptr->resolveFont(d->font.resolve());-
2615 item->d_ptr->resolvePalette(d->palette.resolve());-
2616-
2617-
2618 // Reenable selectionChanged() for individual items-
2619 --d->selectionChanging;-
2620 if (!d->selectionChanging && d->selectedItems.size() != oldSelectedItemSize)
!d->selectionChangingDescription
TRUEnever evaluated
FALSEnever evaluated
d->selectedIte...lectedItemSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2621 emit selectionChanged();
never executed: selectionChanged();
0
2622-
2623 // Deliver post-change notification-
2624 item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);-
2625-
2626 // Update explicit activation-
2627 bool autoActivate = true;-
2628 if (!d->childExplicitActivation && item->d_ptr->explicitActivate)
!d->childExplicitActivationDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->explicitActivateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2629 d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2;
never executed: d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2;
item->d_ptr->wantsActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
2630 if (d->childExplicitActivation && item->isPanel()) {
d->childExplicitActivationDescription
TRUEnever evaluated
FALSEnever evaluated
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2631 if (d->childExplicitActivation == 1)
d->childExplic...ctivation == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2632 setActivePanel(item);
never executed: setActivePanel(item);
0
2633 else-
2634 autoActivate = false;
never executed: autoActivate = false;
0
2635 d->childExplicitActivation = 0;-
2636 } else if (!item->d_ptr->parent) {
never executed: end of block
!item->d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2637 d->childExplicitActivation = 0;-
2638 }
never executed: end of block
0
2639-
2640 // Auto-activate this item's panel if nothing else has been activated-
2641 if (autoActivate) {
autoActivateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2642 if (!d->lastActivePanel && !d->activePanel && item->isPanel()) {
!d->lastActivePanelDescription
TRUEnever evaluated
FALSEnever evaluated
!d->activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2643 if (isActive())
isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2644 setActivePanel(item);
never executed: setActivePanel(item);
0
2645 else-
2646 d->lastActivePanel = item;
never executed: d->lastActivePanel = item;
0
2647 }-
2648 }
never executed: end of block
0
2649-
2650 if (item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges)
item->d_ptr->f...ositionChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
2651 d->registerScenePosItem(item);
never executed: d->registerScenePosItem(item);
0
2652-
2653 // Ensure that newly added items that have subfocus set, gain-
2654 // focus automatically if there isn't a focus item already.-
2655 if (!d->focusItem && item != d->lastFocusItem && item->focusItem() == item)
!d->focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
item != d->lastFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
item->focusItem() == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2656 item->focusItem()->setFocus();
never executed: item->focusItem()->setFocus();
0
2657-
2658 d->updateInputMethodSensitivityInViews();-
2659}
never executed: end of block
0
2660-
2661/*!-
2662 Creates and adds an ellipse item to the scene, and returns the item-
2663 pointer. The geometry of the ellipse is defined by \a rect, and its pen-
2664 and brush are initialized to \a pen and \a brush.-
2665-
2666 Note that the item's geometry is provided in item coordinates, and its-
2667 position is initialized to (0, 0).-
2668-
2669 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2670 QGraphicsScene will emit changed() once control goes back to the event-
2671 loop.-
2672-
2673 \sa addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(),-
2674 addWidget()-
2675*/-
2676QGraphicsEllipseItem *QGraphicsScene::addEllipse(const QRectF &rect, const QPen &pen, const QBrush &brush)-
2677{-
2678 QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect);-
2679 item->setPen(pen);-
2680 item->setBrush(brush);-
2681 addItem(item);-
2682 return item;
never executed: return item;
0
2683}-
2684-
2685/*!-
2686 \fn QGraphicsEllipseItem *QGraphicsScene::addEllipse(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)-
2687 \since 4.3-
2688-
2689 This convenience function is equivalent to calling addEllipse(QRectF(\a x,-
2690 \a y, \a w, \a h), \a pen, \a brush).-
2691*/-
2692-
2693/*!-
2694 Creates and adds a line item to the scene, and returns the item-
2695 pointer. The geometry of the line is defined by \a line, and its pen-
2696 is initialized to \a pen.-
2697-
2698 Note that the item's geometry is provided in item coordinates, and its-
2699 position is initialized to (0, 0).-
2700-
2701 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2702 QGraphicsScene will emit changed() once control goes back to the event-
2703 loop.-
2704-
2705 \sa addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(),-
2706 addWidget()-
2707*/-
2708QGraphicsLineItem *QGraphicsScene::addLine(const QLineF &line, const QPen &pen)-
2709{-
2710 QGraphicsLineItem *item = new QGraphicsLineItem(line);-
2711 item->setPen(pen);-
2712 addItem(item);-
2713 return item;
never executed: return item;
0
2714}-
2715-
2716/*!-
2717 \fn QGraphicsLineItem *QGraphicsScene::addLine(qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen)-
2718 \since 4.3-
2719-
2720 This convenience function is equivalent to calling addLine(QLineF(\a x1,-
2721 \a y1, \a x2, \a y2), \a pen).-
2722*/-
2723-
2724/*!-
2725 Creates and adds a path item to the scene, and returns the item-
2726 pointer. The geometry of the path is defined by \a path, and its pen and-
2727 brush are initialized to \a pen and \a brush.-
2728-
2729 Note that the item's geometry is provided in item coordinates, and its-
2730 position is initialized to (0, 0).-
2731-
2732 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2733 QGraphicsScene will emit changed() once control goes back to the event-
2734 loop.-
2735-
2736 \sa addEllipse(), addLine(), addPixmap(), addRect(), addText(), addItem(),-
2737 addWidget()-
2738*/-
2739QGraphicsPathItem *QGraphicsScene::addPath(const QPainterPath &path, const QPen &pen, const QBrush &brush)-
2740{-
2741 QGraphicsPathItem *item = new QGraphicsPathItem(path);-
2742 item->setPen(pen);-
2743 item->setBrush(brush);-
2744 addItem(item);-
2745 return item;
never executed: return item;
0
2746}-
2747-
2748/*!-
2749 Creates and adds a pixmap item to the scene, and returns the item-
2750 pointer. The pixmap is defined by \a pixmap.-
2751-
2752 Note that the item's geometry is provided in item coordinates, and its-
2753 position is initialized to (0, 0).-
2754-
2755 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2756 QGraphicsScene will emit changed() once control goes back to the event-
2757 loop.-
2758-
2759 \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(),-
2760 addWidget()-
2761*/-
2762QGraphicsPixmapItem *QGraphicsScene::addPixmap(const QPixmap &pixmap)-
2763{-
2764 QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);-
2765 addItem(item);-
2766 return item;
never executed: return item;
0
2767}-
2768-
2769/*!-
2770 Creates and adds a polygon item to the scene, and returns the item-
2771 pointer. The polygon is defined by \a polygon, and its pen and-
2772 brush are initialized to \a pen and \a brush.-
2773-
2774 Note that the item's geometry is provided in item coordinates, and its-
2775 position is initialized to (0, 0).-
2776-
2777 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2778 QGraphicsScene will emit changed() once control goes back to the event-
2779 loop.-
2780-
2781 \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(),-
2782 addWidget()-
2783*/-
2784QGraphicsPolygonItem *QGraphicsScene::addPolygon(const QPolygonF &polygon,-
2785 const QPen &pen, const QBrush &brush)-
2786{-
2787 QGraphicsPolygonItem *item = new QGraphicsPolygonItem(polygon);-
2788 item->setPen(pen);-
2789 item->setBrush(brush);-
2790 addItem(item);-
2791 return item;
never executed: return item;
0
2792}-
2793-
2794/*!-
2795 Creates and adds a rectangle item to the scene, and returns the item-
2796 pointer. The geometry of the rectangle is defined by \a rect, and its pen-
2797 and brush are initialized to \a pen and \a brush.-
2798-
2799 Note that the item's geometry is provided in item coordinates, and its-
2800 position is initialized to (0, 0). For example, if a QRect(50, 50, 100,-
2801 100) is added, its top-left corner will be at (50, 50) relative to the-
2802 origin in the items coordinate system.-
2803-
2804 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2805 QGraphicsScene will emit changed() once control goes back to the event-
2806 loop.-
2807-
2808 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addText(),-
2809 addItem(), addWidget()-
2810*/-
2811QGraphicsRectItem *QGraphicsScene::addRect(const QRectF &rect, const QPen &pen, const QBrush &brush)-
2812{-
2813 QGraphicsRectItem *item = new QGraphicsRectItem(rect);-
2814 item->setPen(pen);-
2815 item->setBrush(brush);-
2816 addItem(item);-
2817 return item;
never executed: return item;
0
2818}-
2819-
2820/*!-
2821 \fn QGraphicsRectItem *QGraphicsScene::addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)-
2822 \since 4.3-
2823-
2824 This convenience function is equivalent to calling addRect(QRectF(\a x,-
2825 \a y, \a w, \a h), \a pen, \a brush).-
2826*/-
2827-
2828/*!-
2829 Creates and adds a text item to the scene, and returns the item-
2830 pointer. The text string is initialized to \a text, and its font-
2831 is initialized to \a font.-
2832-
2833 The item's position is initialized to (0, 0).-
2834-
2835 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2836 QGraphicsScene will emit changed() once control goes back to the event-
2837 loop.-
2838-
2839 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),-
2840 addItem(), addWidget()-
2841*/-
2842QGraphicsTextItem *QGraphicsScene::addText(const QString &text, const QFont &font)-
2843{-
2844 QGraphicsTextItem *item = new QGraphicsTextItem(text);-
2845 item->setFont(font);-
2846 addItem(item);-
2847 return item;
never executed: return item;
0
2848}-
2849-
2850/*!-
2851 Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the-
2852 item pointer. The text string is initialized to \a text, and its font is-
2853 initialized to \a font.-
2854-
2855 The item's position is initialized to (0, 0).-
2856-
2857 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2858 QGraphicsScene will emit changed() once control goes back to the event-
2859 loop.-
2860-
2861 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),-
2862 addItem(), addWidget()-
2863*/-
2864QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, const QFont &font)-
2865{-
2866 QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text);-
2867 item->setFont(font);-
2868 addItem(item);-
2869 return item;
never executed: return item;
0
2870}-
2871-
2872/*!-
2873 Creates a new QGraphicsProxyWidget for \a widget, adds it to the scene,-
2874 and returns a pointer to the proxy. \a wFlags set the default window flags-
2875 for the embedding proxy widget.-
2876-
2877 The item's position is initialized to (0, 0).-
2878-
2879 If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true),-
2880 QGraphicsScene will emit changed() once control goes back to the event-
2881 loop.-
2882-
2883 Note that widgets with the Qt::WA_PaintOnScreen widget attribute-
2884 set and widgets that wrap an external application or controller-
2885 are not supported. Examples are QGLWidget and QAxWidget.-
2886-
2887 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),-
2888 addText(), addSimpleText(), addItem()-
2889*/-
2890QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags)-
2891{-
2892 QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags);-
2893 proxy->setWidget(widget);-
2894 addItem(proxy);-
2895 return proxy;
never executed: return proxy;
0
2896}-
2897-
2898/*!-
2899 Removes the item \a item and all its children from the scene. The-
2900 ownership of \a item is passed on to the caller (i.e.,-
2901 QGraphicsScene will no longer delete \a item when destroyed).-
2902-
2903 \sa addItem()-
2904*/-
2905void QGraphicsScene::removeItem(QGraphicsItem *item)-
2906{-
2907 // ### Refactoring: This function shares much functionality with _q_removeItemLater()-
2908 Q_D(QGraphicsScene);-
2909 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2910 qWarning("QGraphicsScene::removeItem: cannot remove 0-item");-
2911 return;
never executed: return;
0
2912 }-
2913 if (item->scene() != this) {
item->scene() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2914 qWarning("QGraphicsScene::removeItem: item %p's scene (%p)"-
2915 " is different from this scene (%p)",-
2916 item, item->scene(), this);-
2917 return;
never executed: return;
0
2918 }-
2919-
2920 // Notify the item that it's scene is changing to 0, allowing the item to-
2921 // react.-
2922 const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,-
2923 QVariant::fromValue<QGraphicsScene *>(0)));-
2924 QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);-
2925 if (targetScene != 0 && targetScene != this) {
targetScene != 0Description
TRUEnever evaluated
FALSEnever evaluated
targetScene != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2926 targetScene->addItem(item);-
2927 return;
never executed: return;
0
2928 }-
2929-
2930 d->removeItemHelper(item);-
2931-
2932 // Deliver post-change notification-
2933 item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);-
2934-
2935 d->updateInputMethodSensitivityInViews();-
2936}
never executed: end of block
0
2937-
2938/*!-
2939 When the scene is active, this functions returns the scene's current focus-
2940 item, or 0 if no item currently has focus. When the scene is inactive, this-
2941 functions returns the item that will gain input focus when the scene becomes-
2942 active.-
2943-
2944 The focus item receives keyboard input when the scene receives a-
2945 key event.-
2946-
2947 \sa setFocusItem(), QGraphicsItem::hasFocus(), isActive()-
2948*/-
2949QGraphicsItem *QGraphicsScene::focusItem() const-
2950{-
2951 Q_D(const QGraphicsScene);-
2952 return isActive() ? d->focusItem : d->passiveFocusItem;
never executed: return isActive() ? d->focusItem : d->passiveFocusItem;
0
2953}-
2954-
2955/*!-
2956 Sets the scene's focus item to \a item, with the focus reason \a-
2957 focusReason, after removing focus from any previous item that may have had-
2958 focus.-
2959-
2960 If \a item is 0, or if it either does not accept focus (i.e., it does not-
2961 have the QGraphicsItem::ItemIsFocusable flag enabled), or is not visible-
2962 or not enabled, this function only removes focus from any previous-
2963 focusitem.-
2964-
2965 If item is not 0, and the scene does not currently have focus (i.e.,-
2966 hasFocus() returns \c false), this function will call setFocus()-
2967 automatically.-
2968-
2969 \sa focusItem(), hasFocus(), setFocus()-
2970*/-
2971void QGraphicsScene::setFocusItem(QGraphicsItem *item, Qt::FocusReason focusReason)-
2972{-
2973 Q_D(QGraphicsScene);-
2974 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2975 item->setFocus(focusReason);
never executed: item->setFocus(focusReason);
0
2976 else-
2977 d->setFocusItemHelper(item, focusReason);
never executed: d->setFocusItemHelper(item, focusReason);
0
2978}-
2979-
2980/*!-
2981 Returns \c true if the scene has focus; otherwise returns \c false. If the scene-
2982 has focus, it will will forward key events from QKeyEvent to any item that-
2983 has focus.-
2984-
2985 \sa setFocus(), setFocusItem()-
2986*/-
2987bool QGraphicsScene::hasFocus() const-
2988{-
2989 Q_D(const QGraphicsScene);-
2990 return d->hasFocus;
never executed: return d->hasFocus;
0
2991}-
2992-
2993/*!-
2994 Sets focus on the scene by sending a QFocusEvent to the scene, passing \a-
2995 focusReason as the reason. If the scene regains focus after having-
2996 previously lost it while an item had focus, the last focus item will-
2997 receive focus with \a focusReason as the reason.-
2998-
2999 If the scene already has focus, this function does nothing.-
3000-
3001 \sa hasFocus(), clearFocus(), setFocusItem()-
3002*/-
3003void QGraphicsScene::setFocus(Qt::FocusReason focusReason)-
3004{-
3005 Q_D(QGraphicsScene);-
3006 if (d->hasFocus || !isActive())
d->hasFocusDescription
TRUEnever evaluated
FALSEnever evaluated
!isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3007 return;
never executed: return;
0
3008 QFocusEvent event(QEvent::FocusIn, focusReason);-
3009 QCoreApplication::sendEvent(this, &event);-
3010}
never executed: end of block
0
3011-
3012/*!-
3013 Clears focus from the scene. If any item has focus when this function is-
3014 called, it will lose focus, and regain focus again once the scene regains-
3015 focus.-
3016-
3017 A scene that does not have focus ignores key events.-
3018-
3019 \sa hasFocus(), setFocus(), setFocusItem()-
3020*/-
3021void QGraphicsScene::clearFocus()-
3022{-
3023 Q_D(QGraphicsScene);-
3024 if (d->hasFocus) {
d->hasFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
3025 d->hasFocus = false;-
3026 d->passiveFocusItem = d->focusItem;-
3027 setFocusItem(0, Qt::OtherFocusReason);-
3028 }
never executed: end of block
0
3029}
never executed: end of block
0
3030-
3031/*!-
3032 \property QGraphicsScene::stickyFocus-
3033 \brief whether clicking into the scene background will clear focus-
3034-
3035 \since 4.6-
3036-
3037 In a QGraphicsScene with stickyFocus set to true, focus will remain-
3038 unchanged when the user clicks into the scene background or on an item-
3039 that does not accept focus. Otherwise, focus will be cleared.-
3040-
3041 By default, this property is \c false.-
3042-
3043 Focus changes in response to a mouse press. You can reimplement-
3044 mousePressEvent() in a subclass of QGraphicsScene to toggle this property-
3045 based on where the user has clicked.-
3046-
3047 \sa clearFocus(), setFocusItem()-
3048*/-
3049void QGraphicsScene::setStickyFocus(bool enabled)-
3050{-
3051 Q_D(QGraphicsScene);-
3052 d->stickyFocus = enabled;-
3053}
never executed: end of block
0
3054bool QGraphicsScene::stickyFocus() const-
3055{-
3056 Q_D(const QGraphicsScene);-
3057 return d->stickyFocus;
never executed: return d->stickyFocus;
0
3058}-
3059-
3060/*!-
3061 Returns the current mouse grabber item, or 0 if no item is currently-
3062 grabbing the mouse. The mouse grabber item is the item that receives all-
3063 mouse events sent to the scene.-
3064-
3065 An item becomes a mouse grabber when it receives and accepts a-
3066 mouse press event, and it stays the mouse grabber until either of-
3067 the following events occur:-
3068-
3069 \list-
3070 \li If the item receives a mouse release event when there are no other-
3071 buttons pressed, it loses the mouse grab.-
3072 \li If the item becomes invisible (i.e., someone calls \c {item->setVisible(false)}),-
3073 or if it becomes disabled (i.e., someone calls \c {item->setEnabled(false)}),-
3074 it loses the mouse grab.-
3075 \li If the item is removed from the scene, it loses the mouse grab.-
3076 \endlist-
3077-
3078 If the item loses its mouse grab, the scene will ignore all mouse events-
3079 until a new item grabs the mouse (i.e., until a new item receives a mouse-
3080 press event).-
3081*/-
3082QGraphicsItem *QGraphicsScene::mouseGrabberItem() const-
3083{-
3084 Q_D(const QGraphicsScene);-
3085 return !d->mouseGrabberItems.isEmpty() ? d->mouseGrabberItems.last() : 0;
never executed: return !d->mouseGrabberItems.isEmpty() ? d->mouseGrabberItems.last() : 0;
0
3086}-
3087-
3088/*!-
3089 \property QGraphicsScene::backgroundBrush-
3090 \brief the background brush of the scene.-
3091-
3092 Set this property to changes the scene's background to a different color,-
3093 gradient or texture. The default background brush is Qt::NoBrush. The-
3094 background is drawn before (behind) the items.-
3095-
3096 Example:-
3097-
3098 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 3-
3099-
3100 QGraphicsScene::render() calls drawBackground() to draw the scene-
3101 background. For more detailed control over how the background is drawn,-
3102 you can reimplement drawBackground() in a subclass of QGraphicsScene.-
3103*/-
3104QBrush QGraphicsScene::backgroundBrush() const-
3105{-
3106 Q_D(const QGraphicsScene);-
3107 return d->backgroundBrush;
never executed: return d->backgroundBrush;
0
3108}-
3109void QGraphicsScene::setBackgroundBrush(const QBrush &brush)-
3110{-
3111 Q_D(QGraphicsScene);-
3112 d->backgroundBrush = brush;-
3113 foreach (QGraphicsView *view, d->views) {-
3114 view->resetCachedContent();-
3115 view->viewport()->update();-
3116 }
never executed: end of block
0
3117 update();-
3118}
never executed: end of block
0
3119-
3120/*!-
3121 \property QGraphicsScene::foregroundBrush-
3122 \brief the foreground brush of the scene.-
3123-
3124 Change this property to set the scene's foreground to a different-
3125 color, gradient or texture.-
3126-
3127 The foreground is drawn after (on top of) the items. The default-
3128 foreground brush is Qt::NoBrush ( i.e. the foreground is not-
3129 drawn).-
3130-
3131 Example:-
3132-
3133 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 4-
3134-
3135 QGraphicsScene::render() calls drawForeground() to draw the scene-
3136 foreground. For more detailed control over how the foreground is-
3137 drawn, you can reimplement the drawForeground() function in a-
3138 QGraphicsScene subclass.-
3139*/-
3140QBrush QGraphicsScene::foregroundBrush() const-
3141{-
3142 Q_D(const QGraphicsScene);-
3143 return d->foregroundBrush;
never executed: return d->foregroundBrush;
0
3144}-
3145void QGraphicsScene::setForegroundBrush(const QBrush &brush)-
3146{-
3147 Q_D(QGraphicsScene);-
3148 d->foregroundBrush = brush;-
3149 const auto views_ = views();-
3150 for (QGraphicsView *view : views_)-
3151 view->viewport()->update();
never executed: view->viewport()->update();
0
3152 update();-
3153}
never executed: end of block
0
3154-
3155/*!-
3156 This method is used by input methods to query a set of properties of-
3157 the scene to be able to support complex input method operations as support-
3158 for surrounding text and reconversions.-
3159-
3160 The \a query parameter specifies which property is queried.-
3161-
3162 \sa QWidget::inputMethodQuery()-
3163*/-
3164QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const-
3165{-
3166 Q_D(const QGraphicsScene);-
3167 if (!d->focusItem || !(d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
!d->focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
!(d->focusItem...tsInputMethod)Description
TRUEnever evaluated
FALSEnever evaluated
0
3168 return QVariant();
never executed: return QVariant();
0
3169 const QTransform matrix = d->focusItem->sceneTransform();-
3170 QVariant value = d->focusItem->inputMethodQuery(query);-
3171 if (value.type() == QVariant::RectF)
value.type() =...Variant::RectFDescription
TRUEnever evaluated
FALSEnever evaluated
0
3172 value = matrix.mapRect(value.toRectF());
never executed: value = matrix.mapRect(value.toRectF());
0
3173 else if (value.type() == QVariant::PointF)
value.type() =...ariant::PointFDescription
TRUEnever evaluated
FALSEnever evaluated
0
3174 value = matrix.map(value.toPointF());
never executed: value = matrix.map(value.toPointF());
0
3175 else if (value.type() == QVariant::Rect)
value.type() == QVariant::RectDescription
TRUEnever evaluated
FALSEnever evaluated
0
3176 value = matrix.mapRect(value.toRect());
never executed: value = matrix.mapRect(value.toRect());
0
3177 else if (value.type() == QVariant::Point)
value.type() =...Variant::PointDescription
TRUEnever evaluated
FALSEnever evaluated
0
3178 value = matrix.map(value.toPoint());
never executed: value = matrix.map(value.toPoint());
0
3179 return value;
never executed: return value;
0
3180}-
3181-
3182/*!-
3183 \fn void QGraphicsScene::update(const QRectF &rect)-
3184 Schedules a redraw of the area \a rect on the scene.-
3185-
3186 \sa sceneRect(), changed()-
3187*/-
3188void QGraphicsScene::update(const QRectF &rect)-
3189{-
3190 Q_D(QGraphicsScene);-
3191 if (d->updateAll || (rect.isEmpty() && !rect.isNull()))
d->updateAllDescription
TRUEnever evaluated
FALSEnever evaluated
rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3192 return;
never executed: return;
0
3193-
3194 // Check if anyone's connected; if not, we can send updates directly to-
3195 // the views. Otherwise or if there are no views, use old behavior.-
3196 bool directUpdates = !(d->isSignalConnected(d->changedSignalIndex)) && !d->views.isEmpty();
!(d->isSignalC...dSignalIndex))Description
TRUEnever evaluated
FALSEnever evaluated
!d->views.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3197 if (rect.isNull()) {
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3198 d->updateAll = true;-
3199 d->updatedRects.clear();-
3200 if (directUpdates) {
directUpdatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
3201 // Update all views.-
3202 for (int i = 0; i < d->views.size(); ++i)
i < d->views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3203 d->views.at(i)->d_func()->fullUpdatePending = true;
never executed: d->views.at(i)->d_func()->fullUpdatePending = true;
0
3204 }
never executed: end of block
0
3205 } else {
never executed: end of block
0
3206 if (directUpdates) {
directUpdatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
3207 // Update all views.-
3208 for (int i = 0; i < d->views.size(); ++i) {
i < d->views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3209 QGraphicsView *view = d->views.at(i);-
3210 if (view->isTransformed())
view->isTransformed()Description
TRUEnever evaluated
FALSEnever evaluated
0
3211 view->d_func()->updateRectF(view->viewportTransform().mapRect(rect));
never executed: view->d_func()->updateRectF(view->viewportTransform().mapRect(rect));
0
3212 else-
3213 view->d_func()->updateRectF(rect);
never executed: view->d_func()->updateRectF(rect);
0
3214 }-
3215 } else {
never executed: end of block
0
3216 d->updatedRects << rect;-
3217 }
never executed: end of block
0
3218 }-
3219-
3220 if (!d->calledEmitUpdated) {
!d->calledEmitUpdatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
3221 d->calledEmitUpdated = true;-
3222 QMetaObject::invokeMethod(this, "_q_emitUpdated", Qt::QueuedConnection);-
3223 }
never executed: end of block
0
3224}
never executed: end of block
0
3225-
3226/*!-
3227 \fn void QGraphicsScene::update(qreal x, qreal y, qreal w, qreal h)-
3228 \overload-
3229 \since 4.3-
3230-
3231 This function is equivalent to calling update(QRectF(\a x, \a y, \a w,-
3232 \a h));-
3233*/-
3234-
3235/*!-
3236 Invalidates and schedules a redraw of the \a layers in \a rect on the-
3237 scene. Any cached content in \a layers is unconditionally invalidated and-
3238 redrawn.-
3239-
3240 You can use this function overload to notify QGraphicsScene of changes to-
3241 the background or the foreground of the scene. This function is commonly-
3242 used for scenes with tile-based backgrounds to notify changes when-
3243 QGraphicsView has enabled-
3244 \l{QGraphicsView::CacheBackground}{CacheBackground}.-
3245-
3246 Example:-
3247-
3248 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 5-
3249-
3250 Note that QGraphicsView currently supports background caching only (see-
3251 QGraphicsView::CacheBackground). This function is equivalent to calling-
3252 update() if any layer but BackgroundLayer is passed.-
3253-
3254 \sa QGraphicsView::resetCachedContent()-
3255*/-
3256void QGraphicsScene::invalidate(const QRectF &rect, SceneLayers layers)-
3257{-
3258 const auto views_ = views();-
3259 for (QGraphicsView *view : views_)-
3260 view->invalidateScene(rect, layers);
never executed: view->invalidateScene(rect, layers);
0
3261 update(rect);-
3262}
never executed: end of block
0
3263-
3264/*!-
3265 \fn void QGraphicsScene::invalidate(qreal x, qreal y, qreal w, qreal h, SceneLayers layers)-
3266 \overload-
3267 \since 4.3-
3268-
3269 This convenience function is equivalent to calling invalidate(QRectF(\a x, \a-
3270 y, \a w, \a h), \a layers);-
3271*/-
3272-
3273/*!-
3274 Returns a list of all the views that display this scene.-
3275-
3276 \sa QGraphicsView::scene()-
3277*/-
3278QList <QGraphicsView *> QGraphicsScene::views() const-
3279{-
3280 Q_D(const QGraphicsScene);-
3281 return d->views;
never executed: return d->views;
0
3282}-
3283-
3284/*!-
3285 This slot \e advances the scene by one step, by calling-
3286 QGraphicsItem::advance() for all items on the scene. This is done in two-
3287 phases: in the first phase, all items are notified that the scene is about-
3288 to change, and in the second phase all items are notified that they can-
3289 move. In the first phase, QGraphicsItem::advance() is called passing a-
3290 value of 0 as an argument, and 1 is passed in the second phase.-
3291-
3292 Note that you can also use the \l{The Animation Framework}{Animation-
3293 Framework} for animations.-
3294-
3295 \sa QGraphicsItem::advance(), QTimeLine-
3296*/-
3297void QGraphicsScene::advance()-
3298{-
3299 for (int i = 0; i < 2; ++i) {
i < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
3300 const auto items_ = items();-
3301 for (QGraphicsItem *item : items_)-
3302 item->advance(i);
never executed: item->advance(i);
0
3303 }
never executed: end of block
0
3304}
never executed: end of block
0
3305-
3306/*!-
3307 Processes the event \a event, and dispatches it to the respective-
3308 event handlers.-
3309-
3310 In addition to calling the convenience event handlers, this-
3311 function is responsible for converting mouse move events to hover-
3312 events for when there is no mouse grabber item. Hover events are-
3313 delivered directly to items; there is no convenience function for-
3314 them.-
3315-
3316 Unlike QWidget, QGraphicsScene does not have the convenience functions-
3317 \l{QWidget::}{enterEvent()} and \l{QWidget::}{leaveEvent()}. Use this-
3318 function to obtain those events instead.-
3319-
3320 \sa contextMenuEvent(), keyPressEvent(), keyReleaseEvent(),-
3321 mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(),-
3322 mouseDoubleClickEvent(), focusInEvent(), focusOutEvent()-
3323*/-
3324bool QGraphicsScene::event(QEvent *event)-
3325{-
3326 Q_D(QGraphicsScene);-
3327-
3328 switch (event->type()) {-
3329 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
3330 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
3331 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
3332 case QEvent::GraphicsSceneMouseDoubleClick:
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
3333 case QEvent::GraphicsSceneHoverEnter:
never executed: case QEvent::GraphicsSceneHoverEnter:
0
3334 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
3335 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
3336 case QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
3337 case QEvent::TouchUpdate:
never executed: case QEvent::TouchUpdate:
0
3338 case QEvent::TouchEnd:
never executed: case QEvent::TouchEnd:
0
3339 // Reset the under-mouse list to ensure that this event gets fresh-
3340 // item-under-mouse data. Be careful about this list; if people delete-
3341 // items from inside event handlers, this list can quickly end up-
3342 // having stale pointers in it. We need to clear it before dispatching-
3343 // events that use it.-
3344 // ### this should only be cleared if we received a new mouse move event,-
3345 // which relies on us fixing the replay mechanism in QGraphicsView.-
3346 d->cachedItemsUnderMouse.clear();-
3347 default:
code before this statement never executed: default:
never executed: default:
0
3348 break;
never executed: break;
0
3349 }-
3350-
3351 switch (event->type()) {-
3352 case QEvent::GraphicsSceneDragEnter:
never executed: case QEvent::GraphicsSceneDragEnter:
0
3353 dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
3354 break;
never executed: break;
0
3355 case QEvent::GraphicsSceneDragMove:
never executed: case QEvent::GraphicsSceneDragMove:
0
3356 dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
3357 break;
never executed: break;
0
3358 case QEvent::GraphicsSceneDragLeave:
never executed: case QEvent::GraphicsSceneDragLeave:
0
3359 dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
3360 break;
never executed: break;
0
3361 case QEvent::GraphicsSceneDrop:
never executed: case QEvent::GraphicsSceneDrop:
0
3362 dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
3363 break;
never executed: break;
0
3364 case QEvent::GraphicsSceneContextMenu:
never executed: case QEvent::GraphicsSceneContextMenu:
0
3365 contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));-
3366 break;
never executed: break;
0
3367 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
3368 if (!d->focusItem) {
!d->focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3369 QKeyEvent *k = static_cast<QKeyEvent *>(event);-
3370 if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
k->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
k->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
3371 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
!(k->modifiers...:AltModifier))Description
TRUEnever evaluated
FALSEnever evaluated
0
3372 bool res = false;-
3373 if (k->key() == Qt::Key_Backtab
k->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
3374 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
k->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
(k->modifiers(...ShiftModifier)Description
TRUEnever evaluated
FALSEnever evaluated
0
3375 res = focusNextPrevChild(false);-
3376 } else if (k->key() == Qt::Key_Tab) {
never executed: end of block
k->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
0
3377 res = focusNextPrevChild(true);-
3378 }
never executed: end of block
0
3379 if (!res)
!resDescription
TRUEnever evaluated
FALSEnever evaluated
0
3380 event->ignore();
never executed: event->ignore();
0
3381 return true;
never executed: return true;
0
3382 }-
3383 }
never executed: end of block
0
3384 }
never executed: end of block
0
3385 keyPressEvent(static_cast<QKeyEvent *>(event));-
3386 break;
never executed: break;
0
3387 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
3388 keyReleaseEvent(static_cast<QKeyEvent *>(event));-
3389 break;
never executed: break;
0
3390 case QEvent::ShortcutOverride: {
never executed: case QEvent::ShortcutOverride:
0
3391 QGraphicsItem *parent = focusItem();-
3392 while (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3393 d->sendEvent(parent, event);-
3394 if (event->isAccepted())
event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
3395 return true;
never executed: return true;
0
3396 parent = parent->parentItem();-
3397 }
never executed: end of block
0
3398 }-
3399 return false;
never executed: return false;
0
3400 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
3401 {-
3402 QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);-
3403 d->lastSceneMousePos = mouseEvent->scenePos();-
3404 mouseMoveEvent(mouseEvent);-
3405 break;
never executed: break;
0
3406 }-
3407 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
3408 mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
3409 break;
never executed: break;
0
3410 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
3411 mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
3412 break;
never executed: break;
0
3413 case QEvent::GraphicsSceneMouseDoubleClick:
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
3414 mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
3415 break;
never executed: break;
0
3416 case QEvent::GraphicsSceneWheel:
never executed: case QEvent::GraphicsSceneWheel:
0
3417 wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));-
3418 break;
never executed: break;
0
3419 case QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
3420 focusInEvent(static_cast<QFocusEvent *>(event));-
3421 break;
never executed: break;
0
3422 case QEvent::FocusOut:
never executed: case QEvent::FocusOut:
0
3423 focusOutEvent(static_cast<QFocusEvent *>(event));-
3424 break;
never executed: break;
0
3425 case QEvent::GraphicsSceneHoverEnter:
never executed: case QEvent::GraphicsSceneHoverEnter:
0
3426 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
3427 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
3428 {-
3429 QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);-
3430 d->lastSceneMousePos = hoverEvent->scenePos();-
3431 d->dispatchHoverEvent(hoverEvent);-
3432 break;
never executed: break;
0
3433 }-
3434 case QEvent::Leave:
never executed: case QEvent::Leave:
0
3435 // hackieshly unpacking the viewport pointer from the leave event.-
3436 d->leaveScene(reinterpret_cast<QWidget *>(event->d));-
3437 break;
never executed: break;
0
3438 case QEvent::GraphicsSceneHelp:
never executed: case QEvent::GraphicsSceneHelp:
0
3439 helpEvent(static_cast<QGraphicsSceneHelpEvent *>(event));-
3440 break;
never executed: break;
0
3441 case QEvent::InputMethod:
never executed: case QEvent::InputMethod:
0
3442 inputMethodEvent(static_cast<QInputMethodEvent *>(event));-
3443 break;
never executed: break;
0
3444 case QEvent::WindowActivate:
never executed: case QEvent::WindowActivate:
0
3445 if (!d->activationRefCount++) {
!d->activationRefCount++Description
TRUEnever evaluated
FALSEnever evaluated
0
3446 if (d->lastActivePanel) {
d->lastActivePanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
3447 // Activate the last panel.-
3448 d->setActivePanelHelper(d->lastActivePanel, true);-
3449 } else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) {
never executed: end of block
d->tabFocusFirstDescription
TRUEnever evaluated
FALSEnever evaluated
d->tabFocusFirst->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
3450 // Activate the panel of the first item in the tab focus-
3451 // chain.-
3452 d->setActivePanelHelper(d->tabFocusFirst, true);-
3453 } else {
never executed: end of block
0
3454 // Activate all toplevel items.-
3455 QEvent event(QEvent::WindowActivate);-
3456 const auto items_ = items();-
3457 for (QGraphicsItem *item : items_) {-
3458 if (item->isVisible() && !item->isPanel() && !item->parentItem())
item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
!item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
3459 sendEvent(item, &event);
never executed: sendEvent(item, &event);
0
3460 }
never executed: end of block
0
3461 }
never executed: end of block
0
3462 }-
3463 break;
never executed: break;
0
3464 case QEvent::WindowDeactivate:
never executed: case QEvent::WindowDeactivate:
0
3465 if (!--d->activationRefCount) {
!--d->activationRefCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
3466 if (d->activePanel) {
d->activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
3467 // Deactivate the active panel (but keep it so we can-
3468 // reactivate it later).-
3469 QGraphicsItem *lastActivePanel = d->activePanel;-
3470 d->setActivePanelHelper(0, true);-
3471 d->lastActivePanel = lastActivePanel;-
3472 } else {
never executed: end of block
0
3473 // Activate all toplevel items.-
3474 QEvent event(QEvent::WindowDeactivate);-
3475 const auto items_ = items();-
3476 for (QGraphicsItem *item : items_) {-
3477 if (item->isVisible() && !item->isPanel() && !item->parentItem())
item->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
!item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
3478 sendEvent(item, &event);
never executed: sendEvent(item, &event);
0
3479 }
never executed: end of block
0
3480 }
never executed: end of block
0
3481 }-
3482 break;
never executed: break;
0
3483 case QEvent::ApplicationFontChange: {
never executed: case QEvent::ApplicationFontChange:
0
3484 // Resolve the existing scene font.-
3485 d->resolveFont();-
3486 break;
never executed: break;
0
3487 }-
3488 case QEvent::FontChange:
never executed: case QEvent::FontChange:
0
3489 // Update the entire scene when the font changes.-
3490 update();-
3491 break;
never executed: break;
0
3492 case QEvent::ApplicationPaletteChange: {
never executed: case QEvent::ApplicationPaletteChange:
0
3493 // Resolve the existing scene palette.-
3494 d->resolvePalette();-
3495 break;
never executed: break;
0
3496 }-
3497 case QEvent::PaletteChange:
never executed: case QEvent::PaletteChange:
0
3498 // Update the entire scene when the palette changes.-
3499 update();-
3500 break;
never executed: break;
0
3501 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
3502 // Reresolve all widgets' styles. Update all top-level widgets'-
3503 // geometries that do not have an explicit style set.-
3504 update();-
3505 break;
never executed: break;
0
3506 case QEvent::StyleAnimationUpdate:
never executed: case QEvent::StyleAnimationUpdate:
0
3507 // Because QGraphicsItem is not a QObject, QStyle driven-
3508 // animations are forced to update the whole scene-
3509 update();-
3510 break;
never executed: break;
0
3511 case QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
3512 case QEvent::TouchUpdate:
never executed: case QEvent::TouchUpdate:
0
3513 case QEvent::TouchEnd:
never executed: case QEvent::TouchEnd:
0
3514 d->touchEventHandler(static_cast<QTouchEvent *>(event));-
3515 break;
never executed: break;
0
3516#ifndef QT_NO_GESTURES-
3517 case QEvent::Gesture:
never executed: case QEvent::Gesture:
0
3518 case QEvent::GestureOverride:
never executed: case QEvent::GestureOverride:
0
3519 d->gestureEventHandler(static_cast<QGestureEvent *>(event));-
3520 break;
never executed: break;
0
3521#endif // QT_NO_GESTURES-
3522 default:
never executed: default:
0
3523 return QObject::event(event);
never executed: return QObject::event(event);
0
3524 }-
3525 return true;
never executed: return true;
0
3526}-
3527-
3528/*!-
3529 \reimp-
3530-
3531 QGraphicsScene filters QApplication's events to detect palette and font-
3532 changes.-
3533*/-
3534bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event)-
3535{-
3536 if (watched != qApp)
watched != (st...::instance()))Description
TRUEnever evaluated
FALSEnever evaluated
0
3537 return false;
never executed: return false;
0
3538-
3539 switch (event->type()) {-
3540 case QEvent::ApplicationPaletteChange:
never executed: case QEvent::ApplicationPaletteChange:
0
3541 QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));-
3542 break;
never executed: break;
0
3543 case QEvent::ApplicationFontChange:
never executed: case QEvent::ApplicationFontChange:
0
3544 QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange));-
3545 break;
never executed: break;
0
3546 default:
never executed: default:
0
3547 break;
never executed: break;
0
3548 }-
3549 return false;
never executed: return false;
0
3550}-
3551-
3552/*!-
3553 This event handler, for event \a contextMenuEvent, can be reimplemented in-
3554 a subclass to receive context menu events. The default implementation-
3555 forwards the event to the topmost visible item that accepts context menu events at-
3556 the position of the event. If no items accept context menu events at this-
3557 position, the event is ignored.-
3558-
3559 Note: See items() for a definition of which items are considered visible by this function.-
3560-
3561 \sa QGraphicsItem::contextMenuEvent()-
3562*/-
3563void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)-
3564{-
3565 Q_D(QGraphicsScene);-
3566 // Ignore by default.-
3567 contextMenuEvent->ignore();-
3568-
3569 // Send the event to all items at this position until one item accepts the-
3570 // event.-
3571 const auto items = d->itemsAtPosition(contextMenuEvent->screenPos(),-
3572 contextMenuEvent->scenePos(),-
3573 contextMenuEvent->widget());-
3574 for (QGraphicsItem *item : items) {-
3575 contextMenuEvent->setPos(item->d_ptr->genericMapFromScene(contextMenuEvent->scenePos(),-
3576 contextMenuEvent->widget()));-
3577 contextMenuEvent->accept();-
3578 if (!d->sendEvent(item, contextMenuEvent))
!d->sendEvent(...textMenuEvent)Description
TRUEnever evaluated
FALSEnever evaluated
0
3579 break;
never executed: break;
0
3580-
3581 if (contextMenuEvent->isAccepted())
contextMenuEvent->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
3582 break;
never executed: break;
0
3583 }
never executed: end of block
0
3584}
never executed: end of block
0
3585-
3586/*!-
3587 This event handler, for event \a event, can be reimplemented in a subclass-
3588 to receive drag enter events for the scene.-
3589-
3590 The default implementation accepts the event and prepares the scene to-
3591 accept drag move events.-
3592-
3593 \sa QGraphicsItem::dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(),-
3594 dropEvent()-
3595*/-
3596void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)-
3597{-
3598 Q_D(QGraphicsScene);-
3599 d->dragDropItem = 0;-
3600 d->lastDropAction = Qt::IgnoreAction;-
3601 event->accept();-
3602}
never executed: end of block
0
3603-
3604/*!-
3605 This event handler, for event \a event, can be reimplemented in a subclass-
3606 to receive drag move events for the scene.-
3607-
3608 Note: See items() for a definition of which items are considered visible by this function.-
3609-
3610 \sa QGraphicsItem::dragMoveEvent(), dragEnterEvent(), dragLeaveEvent(),-
3611 dropEvent()-
3612*/-
3613void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)-
3614{-
3615 Q_D(QGraphicsScene);-
3616 event->ignore();-
3617-
3618 if (!d->mouseGrabberItems.isEmpty()) {
!d->mouseGrabb...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3619 // Mouse grabbers that start drag events lose the mouse grab.-
3620 d->clearMouseGrabber();-
3621 d->mouseGrabberButtonDownPos.clear();-
3622 d->mouseGrabberButtonDownScenePos.clear();-
3623 d->mouseGrabberButtonDownScreenPos.clear();-
3624 }
never executed: end of block
0
3625-
3626 bool eventDelivered = false;-
3627-
3628 // Find the topmost enabled items under the cursor. They are all-
3629 // candidates for accepting drag & drop events.-
3630 const auto items = d->itemsAtPosition(event->screenPos(),-
3631 event->scenePos(),-
3632 event->widget());-
3633 for (QGraphicsItem *item : items) {-
3634 if (!item->isEnabled() || !item->acceptDrops())
!item->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!item->acceptDrops()Description
TRUEnever evaluated
FALSEnever evaluated
0
3635 continue;
never executed: continue;
0
3636-
3637 if (item != d->dragDropItem) {
item != d->dragDropItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3638 // Enter the new drag drop item. If it accepts the event, we send-
3639 // the leave to the parent item.-
3640 QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter);-
3641 d->cloneDragDropEvent(&dragEnter, event);-
3642 dragEnter.setDropAction(event->proposedAction());-
3643 d->sendDragDropEvent(item, &dragEnter);-
3644 event->setAccepted(dragEnter.isAccepted());-
3645 event->setDropAction(dragEnter.dropAction());-
3646 if (!event->isAccepted()) {
!event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
3647 // Propagate to the item under-
3648 continue;
never executed: continue;
0
3649 }-
3650-
3651 d->lastDropAction = event->dropAction();-
3652-
3653 if (d->dragDropItem) {
d->dragDropItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3654 // Leave the last drag drop item. A perfect implementation-
3655 // would set the position of this event to the point where-
3656 // this event and the last event intersect with the item's-
3657 // shape, but that's not easy to do. :-)-
3658 QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);-
3659 d->cloneDragDropEvent(&dragLeave, event);-
3660 d->sendDragDropEvent(d->dragDropItem, &dragLeave);-
3661 }
never executed: end of block
0
3662-
3663 // We've got a new drag & drop item-
3664 d->dragDropItem = item;-
3665 }
never executed: end of block
0
3666-
3667 // Send the move event.-
3668 event->setDropAction(d->lastDropAction);-
3669 event->accept();-
3670 d->sendDragDropEvent(item, event);-
3671 if (event->isAccepted())
event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
3672 d->lastDropAction = event->dropAction();
never executed: d->lastDropAction = event->dropAction();
0
3673 eventDelivered = true;-
3674 break;
never executed: break;
0
3675 }-
3676-
3677 if (!eventDelivered) {
!eventDeliveredDescription
TRUEnever evaluated
FALSEnever evaluated
0
3678 if (d->dragDropItem) {
d->dragDropItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3679 // Leave the last drag drop item-
3680 QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);-
3681 d->cloneDragDropEvent(&dragLeave, event);-
3682 d->sendDragDropEvent(d->dragDropItem, &dragLeave);-
3683 d->dragDropItem = 0;-
3684 }
never executed: end of block
0
3685 // Propagate-
3686 event->setDropAction(Qt::IgnoreAction);-
3687 }
never executed: end of block
0
3688}
never executed: end of block
0
3689-
3690/*!-
3691 This event handler, for event \a event, can be reimplemented in a subclass-
3692 to receive drag leave events for the scene.-
3693-
3694 \sa QGraphicsItem::dragLeaveEvent(), dragEnterEvent(), dragMoveEvent(),-
3695 dropEvent()-
3696*/-
3697void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)-
3698{-
3699 Q_D(QGraphicsScene);-
3700 if (d->dragDropItem) {
d->dragDropItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3701 // Leave the last drag drop item-
3702 d->sendDragDropEvent(d->dragDropItem, event);-
3703 d->dragDropItem = 0;-
3704 }
never executed: end of block
0
3705}
never executed: end of block
0
3706-
3707/*!-
3708 This event handler, for event \a event, can be reimplemented in a subclass-
3709 to receive drop events for the scene.-
3710-
3711 \sa QGraphicsItem::dropEvent(), dragEnterEvent(), dragMoveEvent(),-
3712 dragLeaveEvent()-
3713*/-
3714void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event)-
3715{-
3716 Q_UNUSED(event);-
3717 Q_D(QGraphicsScene);-
3718 if (d->dragDropItem) {
d->dragDropItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3719 // Drop on the last drag drop item-
3720 d->sendDragDropEvent(d->dragDropItem, event);-
3721 d->dragDropItem = 0;-
3722 }
never executed: end of block
0
3723}
never executed: end of block
0
3724-
3725/*!-
3726 This event handler, for event \a focusEvent, can be reimplemented in a-
3727 subclass to receive focus in events.-
3728-
3729 The default implementation sets focus on the scene, and then on the last-
3730 focus item.-
3731-
3732 \sa QGraphicsItem::focusOutEvent()-
3733*/-
3734void QGraphicsScene::focusInEvent(QFocusEvent *focusEvent)-
3735{-
3736 Q_D(QGraphicsScene);-
3737-
3738 d->hasFocus = true;-
3739 switch (focusEvent->reason()) {-
3740 case Qt::TabFocusReason:
never executed: case Qt::TabFocusReason:
0
3741 if (!focusNextPrevChild(true))
!focusNextPrevChild(true)Description
TRUEnever evaluated
FALSEnever evaluated
0
3742 focusEvent->ignore();
never executed: focusEvent->ignore();
0
3743 break;
never executed: break;
0
3744 case Qt::BacktabFocusReason:
never executed: case Qt::BacktabFocusReason:
0
3745 if (!focusNextPrevChild(false))
!focusNextPrevChild(false)Description
TRUEnever evaluated
FALSEnever evaluated
0
3746 focusEvent->ignore();
never executed: focusEvent->ignore();
0
3747 break;
never executed: break;
0
3748 default:
never executed: default:
0
3749 if (d->passiveFocusItem) {
d->passiveFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3750 // Set focus on the last focus item-
3751 setFocusItem(d->passiveFocusItem, focusEvent->reason());-
3752 }
never executed: end of block
0
3753 break;
never executed: break;
0
3754 }-
3755}-
3756-
3757/*!-
3758 This event handler, for event \a focusEvent, can be reimplemented in a-
3759 subclass to receive focus out events.-
3760-
3761 The default implementation removes focus from any focus item, then removes-
3762 focus from the scene.-
3763-
3764 \sa QGraphicsItem::focusInEvent()-
3765*/-
3766void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)-
3767{-
3768 Q_D(QGraphicsScene);-
3769 d->hasFocus = false;-
3770 d->passiveFocusItem = d->focusItem;-
3771 setFocusItem(0, focusEvent->reason());-
3772-
3773 // Remove all popups when the scene loses focus.-
3774 if (!d->popupWidgets.isEmpty())
!d->popupWidgets.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3775 d->removePopup(d->popupWidgets.constFirst());
never executed: d->removePopup(d->popupWidgets.constFirst());
0
3776}
never executed: end of block
0
3777-
3778/*!-
3779 This event handler, for event \a helpEvent, can be-
3780 reimplemented in a subclass to receive help events. The events-
3781 are of type QEvent::ToolTip, which are created when a tooltip is-
3782 requested.-
3783-
3784 The default implementation shows the tooltip of the topmost-
3785 visible item, i.e., the item with the highest z-value, at the mouse-
3786 cursor position. If no item has a tooltip set, this function-
3787 does nothing.-
3788-
3789 Note: See items() for a definition of which items are considered visible by this function.-
3790-
3791 \sa QGraphicsItem::toolTip(), QGraphicsSceneHelpEvent-
3792*/-
3793void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)-
3794{-
3795#ifdef QT_NO_TOOLTIP-
3796 Q_UNUSED(helpEvent);-
3797#else-
3798 // Find the first item that does tooltips-
3799 Q_D(QGraphicsScene);-
3800 QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(),-
3801 helpEvent->scenePos(),-
3802 helpEvent->widget());-
3803 QGraphicsItem *toolTipItem = 0;-
3804 for (int i = 0; i < itemsAtPos.size(); ++i) {
i < itemsAtPos.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3805 QGraphicsItem *tmp = itemsAtPos.at(i);-
3806 if (tmp->d_func()->isProxyWidget()) {
tmp->d_func()->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
3807 // if the item is a proxy widget, the event is forwarded to it-
3808 sendEvent(tmp, helpEvent);-
3809 if (helpEvent->isAccepted())
helpEvent->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
3810 return;
never executed: return;
0
3811 }
never executed: end of block
0
3812 if (!tmp->toolTip().isEmpty()) {
!tmp->toolTip().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3813 toolTipItem = tmp;-
3814 break;
never executed: break;
0
3815 }-
3816 }
never executed: end of block
0
3817-
3818 // Show or hide the tooltip-
3819 QString text;-
3820 QPoint point;-
3821 if (toolTipItem && !toolTipItem->toolTip().isEmpty()) {
toolTipItemDescription
TRUEnever evaluated
FALSEnever evaluated
!toolTipItem->...ip().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3822 text = toolTipItem->toolTip();-
3823 point = helpEvent->screenPos();-
3824 }
never executed: end of block
0
3825 QToolTip::showText(point, text, helpEvent->widget());-
3826 helpEvent->setAccepted(!text.isEmpty());-
3827#endif-
3828}
never executed: end of block
0
3829-
3830bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const-
3831{-
3832 return (item->d_ptr->acceptsHover
never executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
0
3833 || (item->d_ptr->isWidget
never executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
0
3834 && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration()))
never executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
0
3835 && !item->isBlockedByModalPanel();
never executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
0
3836}-
3837-
3838/*!-
3839 This event handler, for event \a hoverEvent, can be reimplemented in a-
3840 subclass to receive hover enter events. The default implementation-
3841 forwards the event to the topmost visible item that accepts hover events at the-
3842 scene position from the event.-
3843-
3844 Note: See items() for a definition of which items are considered visible by this function.-
3845-
3846 \sa QGraphicsItem::hoverEvent(), QGraphicsItem::setAcceptHoverEvents()-
3847*/-
3848bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent)-
3849{-
3850 if (allItemsIgnoreHoverEvents)
allItemsIgnoreHoverEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3851 return false;
never executed: return false;
0
3852-
3853 // Find the first item that accepts hover events, reusing earlier-
3854 // calculated data is possible.-
3855 if (cachedItemsUnderMouse.isEmpty()) {
cachedItemsUnd...ouse.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3856 cachedItemsUnderMouse = itemsAtPosition(hoverEvent->screenPos(),-
3857 hoverEvent->scenePos(),-
3858 hoverEvent->widget());-
3859 }
never executed: end of block
0
3860-
3861 QGraphicsItem *item = 0;-
3862 for (int i = 0; i < cachedItemsUnderMouse.size(); ++i) {
i < cachedItem...erMouse.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
3863 QGraphicsItem *tmp = cachedItemsUnderMouse.at(i);-
3864 if (itemAcceptsHoverEvents_helper(tmp)) {
itemAcceptsHov...ts_helper(tmp)Description
TRUEnever evaluated
FALSEnever evaluated
0
3865 item = tmp;-
3866 break;
never executed: break;
0
3867 }-
3868 }
never executed: end of block
0
3869-
3870 // Find the common ancestor item for the new topmost hoverItem and the-
3871 // last item in the hoverItem list.-
3872 QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : 0;
itemDescription
TRUEnever evaluated
FALSEnever evaluated
!hoverItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3873 while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
commonAncestorItemDescription
TRUEnever evaluated
FALSEnever evaluated
!itemAcceptsHo...nAncestorItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
3874 commonAncestorItem = commonAncestorItem->parentItem();
never executed: commonAncestorItem = commonAncestorItem->parentItem();
0
3875 if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
commonAncestorItemDescription
TRUEnever evaluated
FALSEnever evaluated
commonAncestor... item->panel()Description
TRUEnever evaluated
FALSEnever evaluated
0
3876 // The common ancestor isn't in the same panel as the two hovered-
3877 // items.-
3878 commonAncestorItem = 0;-
3879 }
never executed: end of block
0
3880-
3881 // Check if the common ancestor item is known.-
3882 int index = commonAncestorItem ? hoverItems.indexOf(commonAncestorItem) : -1;
commonAncestorItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3883 // Send hover leaves to any existing hovered children of the common-
3884 // ancestor item.-
3885 for (int i = hoverItems.size() - 1; i > index; --i) {
i > indexDescription
TRUEnever evaluated
FALSEnever evaluated
0
3886 QGraphicsItem *lastItem = hoverItems.takeLast();-
3887 if (itemAcceptsHoverEvents_helper(lastItem))
itemAcceptsHov...lper(lastItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
3888 sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent);
never executed: sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent);
0
3889 }
never executed: end of block
0
3890-
3891 // Item is a child of a known item. Generate enter events for the-
3892 // missing links.-
3893 QList<QGraphicsItem *> parents;-
3894 QGraphicsItem *parent = item;-
3895 while (parent && parent != commonAncestorItem) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
parent != commonAncestorItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3896 parents.append(parent);-
3897 if (parent->isPanel()) {
parent->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
3898 // Stop at the panel - we don't deliver beyond this point.-
3899 break;
never executed: break;
0
3900 }-
3901 parent = parent->parentItem();-
3902 }
never executed: end of block
0
3903 for (auto it = parents.crbegin(), end = parents.crend(); it != end; ++it) {
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
3904 QGraphicsItem *parent = *it;-
3905 hoverItems << parent;-
3906 if (itemAcceptsHoverEvents_helper(parent))
itemAcceptsHov...helper(parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
3907 sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent);
never executed: sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent);
0
3908 }
never executed: end of block
0
3909-
3910 // Generate a move event for the item itself-
3911 if (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3912 && !hoverItems.isEmpty()
!hoverItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3913 && item == hoverItems.constLast()) {
item == hoverItems.constLast()Description
TRUEnever evaluated
FALSEnever evaluated
0
3914 sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent);-
3915 return true;
never executed: return true;
0
3916 }-
3917 return false;
never executed: return false;
0
3918}-
3919-
3920/*!-
3921 \internal-
3922-
3923 Handles all actions necessary to clean up the scene when the mouse leaves-
3924 the view.-
3925*/-
3926void QGraphicsScenePrivate::leaveScene(QWidget *viewport)-
3927{-
3928#ifndef QT_NO_TOOLTIP-
3929 QToolTip::hideText();-
3930#endif-
3931 QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());-
3932 // Send HoverLeave events to all existing hover items, topmost first.-
3933 QGraphicsSceneHoverEvent hoverEvent;-
3934 hoverEvent.setWidget(viewport);-
3935-
3936 if (view) {
viewDescription
TRUEnever evaluated
FALSEnever evaluated
0
3937 QPoint cursorPos = QCursor::pos();-
3938 hoverEvent.setScenePos(view->mapToScene(viewport->mapFromGlobal(cursorPos)));-
3939 hoverEvent.setLastScenePos(hoverEvent.scenePos());-
3940 hoverEvent.setScreenPos(cursorPos);-
3941 hoverEvent.setLastScreenPos(hoverEvent.screenPos());-
3942 }
never executed: end of block
0
3943-
3944 while (!hoverItems.isEmpty()) {
!hoverItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3945 QGraphicsItem *lastItem = hoverItems.takeLast();-
3946 if (itemAcceptsHoverEvents_helper(lastItem))
itemAcceptsHov...lper(lastItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
3947 sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, &hoverEvent);
never executed: sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, &hoverEvent);
0
3948 }
never executed: end of block
0
3949}
never executed: end of block
0
3950-
3951/*!-
3952 This event handler, for event \a keyEvent, can be reimplemented in a-
3953 subclass to receive keypress events. The default implementation forwards-
3954 the event to current focus item.-
3955-
3956 \sa QGraphicsItem::keyPressEvent(), focusItem()-
3957*/-
3958void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent)-
3959{-
3960 // ### Merge this function with keyReleaseEvent; they are identical-
3961 // ### (except this comment).-
3962 Q_D(QGraphicsScene);-
3963 QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.constLast() : 0;
!d->keyboardGr...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3964 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3965 item = focusItem();
never executed: item = focusItem();
0
3966 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3967 QGraphicsItem *p = item;-
3968 do {-
3969 // Accept the event by default-
3970 keyEvent->accept();-
3971 // Send it; QGraphicsItem::keyPressEvent ignores it. If the event-
3972 // is filtered out, stop propagating it.-
3973 if (p->isBlockedByModalPanel())
p->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
3974 break;
never executed: break;
0
3975 if (!d->sendEvent(p, keyEvent))
!d->sendEvent(p, keyEvent)Description
TRUEnever evaluated
FALSEnever evaluated
0
3976 break;
never executed: break;
0
3977 } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
never executed: end of block
!keyEvent->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
!p->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
(p = p->parentItem())Description
TRUEnever evaluated
FALSEnever evaluated
0
3978 } else {
never executed: end of block
0
3979 keyEvent->ignore();-
3980 }
never executed: end of block
0
3981}-
3982-
3983/*!-
3984 This event handler, for event \a keyEvent, can be reimplemented in a-
3985 subclass to receive key release events. The default implementation-
3986 forwards the event to current focus item.-
3987-
3988 \sa QGraphicsItem::keyReleaseEvent(), focusItem()-
3989*/-
3990void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)-
3991{-
3992 // ### Merge this function with keyPressEvent; they are identical (except-
3993 // ### this comment).-
3994 Q_D(QGraphicsScene);-
3995 QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.constLast() : 0;
!d->keyboardGr...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
3996 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3997 item = focusItem();
never executed: item = focusItem();
0
3998 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3999 QGraphicsItem *p = item;-
4000 do {-
4001 // Accept the event by default-
4002 keyEvent->accept();-
4003 // Send it; QGraphicsItem::keyPressEvent ignores it. If the event-
4004 // is filtered out, stop propagating it.-
4005 if (p->isBlockedByModalPanel())
p->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
4006 break;
never executed: break;
0
4007 if (!d->sendEvent(p, keyEvent))
!d->sendEvent(p, keyEvent)Description
TRUEnever evaluated
FALSEnever evaluated
0
4008 break;
never executed: break;
0
4009 } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
never executed: end of block
!keyEvent->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
!p->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
(p = p->parentItem())Description
TRUEnever evaluated
FALSEnever evaluated
0
4010 } else {
never executed: end of block
0
4011 keyEvent->ignore();-
4012 }
never executed: end of block
0
4013}-
4014-
4015/*!-
4016 This event handler, for event \a mouseEvent, can be reimplemented-
4017 in a subclass to receive mouse press events for the scene.-
4018-
4019 The default implementation depends on the state of the scene. If-
4020 there is a mouse grabber item, then the event is sent to the mouse-
4021 grabber. Otherwise, it is forwarded to the topmost visible item that-
4022 accepts mouse events at the scene position from the event, and-
4023 that item promptly becomes the mouse grabber item.-
4024-
4025 If there is no item at the given position on the scene, the-
4026 selection area is reset, any focus item loses its input focus, and-
4027 the event is then ignored.-
4028-
4029 Note: See items() for a definition of which items are considered visible by this function.-
4030-
4031 \sa QGraphicsItem::mousePressEvent(),-
4032 QGraphicsItem::setAcceptedMouseButtons()-
4033*/-
4034void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)-
4035{-
4036 Q_D(QGraphicsScene);-
4037 if (d->mouseGrabberItems.isEmpty()) {
d->mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4038 // Dispatch hover events-
4039 QGraphicsSceneHoverEvent hover;-
4040 _q_hoverFromMouseEvent(&hover, mouseEvent);-
4041 d->dispatchHoverEvent(&hover);-
4042 }
never executed: end of block
0
4043-
4044 d->mousePressEventHandler(mouseEvent);-
4045}
never executed: end of block
0
4046-
4047/*!-
4048 This event handler, for event \a mouseEvent, can be reimplemented-
4049 in a subclass to receive mouse move events for the scene.-
4050-
4051 The default implementation depends on the mouse grabber state. If there is-
4052 a mouse grabber item, the event is sent to the mouse grabber. If there-
4053 are any items that accept hover events at the current position, the event-
4054 is translated into a hover event and accepted; otherwise it's ignored.-
4055-
4056 \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseReleaseEvent(),-
4057 QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons()-
4058*/-
4059void QGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)-
4060{-
4061 Q_D(QGraphicsScene);-
4062 if (d->mouseGrabberItems.isEmpty()) {
d->mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4063 if (mouseEvent->buttons())
mouseEvent->buttons()Description
TRUEnever evaluated
FALSEnever evaluated
0
4064 return;
never executed: return;
0
4065 QGraphicsSceneHoverEvent hover;-
4066 _q_hoverFromMouseEvent(&hover, mouseEvent);-
4067 mouseEvent->setAccepted(d->dispatchHoverEvent(&hover));-
4068 return;
never executed: return;
0
4069 }-
4070-
4071 // Forward the event to the mouse grabber-
4072 d->sendMouseEvent(mouseEvent);-
4073 mouseEvent->accept();-
4074}
never executed: end of block
0
4075-
4076/*!-
4077 This event handler, for event \a mouseEvent, can be reimplemented-
4078 in a subclass to receive mouse release events for the scene.-
4079-
4080 The default implementation depends on the mouse grabber state. If-
4081 there is no mouse grabber, the event is ignored. Otherwise, if-
4082 there is a mouse grabber item, the event is sent to the mouse-
4083 grabber. If this mouse release represents the last pressed button-
4084 on the mouse, the mouse grabber item then loses the mouse grab.-
4085-
4086 \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(),-
4087 QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons()-
4088*/-
4089void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)-
4090{-
4091 Q_D(QGraphicsScene);-
4092 if (d->mouseGrabberItems.isEmpty()) {
d->mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4093 mouseEvent->ignore();-
4094 return;
never executed: return;
0
4095 }-
4096-
4097 // Forward the event to the mouse grabber-
4098 d->sendMouseEvent(mouseEvent);-
4099 mouseEvent->accept();-
4100-
4101 // Reset the mouse grabber when the last mouse button has been released.-
4102 if (!mouseEvent->buttons()) {
!mouseEvent->buttons()Description
TRUEnever evaluated
FALSEnever evaluated
0
4103 if (!d->mouseGrabberItems.isEmpty()) {
!d->mouseGrabb...tems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4104 d->lastMouseGrabberItem = d->mouseGrabberItems.constLast();-
4105 if (d->lastMouseGrabberItemHasImplicitMouseGrab)
d->lastMouseGr...licitMouseGrabDescription
TRUEnever evaluated
FALSEnever evaluated
0
4106 d->mouseGrabberItems.constLast()->ungrabMouse();
never executed: d->mouseGrabberItems.constLast()->ungrabMouse();
0
4107 } else {
never executed: end of block
0
4108 d->lastMouseGrabberItem = 0;-
4109 }
never executed: end of block
0
4110-
4111 // Generate a hoverevent-
4112 QGraphicsSceneHoverEvent hoverEvent;-
4113 _q_hoverFromMouseEvent(&hoverEvent, mouseEvent);-
4114 d->dispatchHoverEvent(&hoverEvent);-
4115 }
never executed: end of block
0
4116}
never executed: end of block
0
4117-
4118/*!-
4119 This event handler, for event \a mouseEvent, can be reimplemented-
4120 in a subclass to receive mouse doubleclick events for the scene.-
4121-
4122 If someone doubleclicks on the scene, the scene will first receive-
4123 a mouse press event, followed by a release event (i.e., a click),-
4124 then a doubleclick event, and finally a release event. If the-
4125 doubleclick event is delivered to a different item than the one-
4126 that received the first press and release, it will be delivered as-
4127 a press event. However, tripleclick events are not delivered as-
4128 doubleclick events in this case.-
4129-
4130 The default implementation is similar to mousePressEvent().-
4131-
4132 Note: See items() for a definition of which items are considered visible by this function.-
4133-
4134 \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(),-
4135 QGraphicsItem::mouseReleaseEvent(), QGraphicsItem::setAcceptedMouseButtons()-
4136*/-
4137void QGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)-
4138{-
4139 Q_D(QGraphicsScene);-
4140 d->mousePressEventHandler(mouseEvent);-
4141}
never executed: end of block
0
4142-
4143/*!-
4144 This event handler, for event \a wheelEvent, can be reimplemented in a-
4145 subclass to receive mouse wheel events for the scene.-
4146-
4147 By default, the event is delivered to the topmost visible item under the-
4148 cursor. If ignored, the event propagates to the item beneath, and again-
4149 until the event is accepted, or it reaches the scene. If no items accept-
4150 the event, it is ignored.-
4151-
4152 Note: See items() for a definition of which items are considered visible by this function.-
4153-
4154 \sa QGraphicsItem::wheelEvent()-
4155*/-
4156void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)-
4157{-
4158 Q_D(QGraphicsScene);-
4159 const QList<QGraphicsItem *> wheelCandidates = d->itemsAtPosition(wheelEvent->screenPos(),-
4160 wheelEvent->scenePos(),-
4161 wheelEvent->widget());-
4162-
4163#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
4164 // On Mac, ignore the event if the first item under the mouse is not the last opened-
4165 // popup (or one of its descendant)-
4166 if (!d->popupWidgets.isEmpty() && !wheelCandidates.isEmpty() && wheelCandidates.first() != d->popupWidgets.back() && !d->popupWidgets.back()->isAncestorOf(wheelCandidates.first())) {-
4167 wheelEvent->accept();-
4168 return;-
4169 }-
4170#else-
4171 // Find the first popup under the mouse (including the popup's descendants) starting from the last.-
4172 // Remove all popups after the one found, or all or them if no popup is under the mouse.-
4173 // Then continue with the event.-
4174 QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.constEnd();-
4175 while (--iter >= d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) {
--iter >= d->p...s.constBegin()Description
TRUEnever evaluated
FALSEnever evaluated
!wheelCandidates.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4176 if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first()))
wheelCandidate...rst() == *iterDescription
TRUEnever evaluated
FALSEnever evaluated
(*iter)->isAnc...dates.first())Description
TRUEnever evaluated
FALSEnever evaluated
0
4177 break;
never executed: break;
0
4178 d->removePopup(*iter);-
4179 }
never executed: end of block
0
4180#endif-
4181-
4182 bool hasSetFocus = false;-
4183 for (QGraphicsItem *item : wheelCandidates) {-
4184 if (!hasSetFocus && item->isEnabled()
!hasSetFocusDescription
TRUEnever evaluated
FALSEnever evaluated
item->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
4185 && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
(item->flags()...emIsFocusable)Description
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->mouseSetsFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
4186 if (item->isWidget() && static_cast<QGraphicsWidget *>(item)->focusPolicy() == Qt::WheelFocus) {
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
static_cast<QG...Qt::WheelFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
4187 hasSetFocus = true;-
4188 if (item != focusItem())
item != focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
4189 setFocusItem(item, Qt::MouseFocusReason);
never executed: setFocusItem(item, Qt::MouseFocusReason);
0
4190 }
never executed: end of block
0
4191 }
never executed: end of block
0
4192-
4193 wheelEvent->setPos(item->d_ptr->genericMapFromScene(wheelEvent->scenePos(),-
4194 wheelEvent->widget()));-
4195 wheelEvent->accept();-
4196 bool isPanel = item->isPanel();-
4197 bool ret = d->sendEvent(item, wheelEvent);-
4198-
4199 if (ret && (isPanel || wheelEvent->isAccepted()))
retDescription
TRUEnever evaluated
FALSEnever evaluated
isPanelDescription
TRUEnever evaluated
FALSEnever evaluated
wheelEvent->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
4200 break;
never executed: break;
0
4201 }
never executed: end of block
0
4202}
never executed: end of block
0
4203-
4204/*!-
4205 This event handler, for event \a event, can be reimplemented in a-
4206 subclass to receive input method events for the scene.-
4207-
4208 The default implementation forwards the event to the focusItem().-
4209 If no item currently has focus or the current focus item does not-
4210 accept input methods, this function does nothing.-
4211-
4212 \sa QGraphicsItem::inputMethodEvent()-
4213*/-
4214void QGraphicsScene::inputMethodEvent(QInputMethodEvent *event)-
4215{-
4216 Q_D(QGraphicsScene);-
4217 if (d->focusItem && (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
d->focusItemDescription
TRUEnever evaluated
FALSEnever evaluated
(d->focusItem-...tsInputMethod)Description
TRUEnever evaluated
FALSEnever evaluated
0
4218 d->sendEvent(d->focusItem, event);
never executed: d->sendEvent(d->focusItem, event);
0
4219}
never executed: end of block
0
4220-
4221/*!-
4222 Draws the background of the scene using \a painter, before any items and-
4223 the foreground are drawn. Reimplement this function to provide a custom-
4224 background for the scene.-
4225-
4226 All painting is done in \e scene coordinates. The \a rect-
4227 parameter is the exposed rectangle.-
4228-
4229 If all you want is to define a color, texture, or gradient for the-
4230 background, you can call setBackgroundBrush() instead.-
4231-
4232 \sa drawForeground(), drawItems()-
4233*/-
4234void QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)-
4235{-
4236 Q_D(QGraphicsScene);-
4237-
4238 if (d->backgroundBrush.style() != Qt::NoBrush) {
d->backgroundB...!= Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
4239 if (d->painterStateProtection)
d->painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4240 painter->save();
never executed: painter->save();
0
4241 painter->setBrushOrigin(0, 0);-
4242 painter->fillRect(rect, backgroundBrush());-
4243 if (d->painterStateProtection)
d->painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4244 painter->restore();
never executed: painter->restore();
0
4245 }
never executed: end of block
0
4246}
never executed: end of block
0
4247-
4248/*!-
4249 Draws the foreground of the scene using \a painter, after the background-
4250 and all items have been drawn. Reimplement this function to provide a-
4251 custom foreground for the scene.-
4252-
4253 All painting is done in \e scene coordinates. The \a rect-
4254 parameter is the exposed rectangle.-
4255-
4256 If all you want is to define a color, texture or gradient for the-
4257 foreground, you can call setForegroundBrush() instead.-
4258-
4259 \sa drawBackground(), drawItems()-
4260*/-
4261void QGraphicsScene::drawForeground(QPainter *painter, const QRectF &rect)-
4262{-
4263 Q_D(QGraphicsScene);-
4264-
4265 if (d->foregroundBrush.style() != Qt::NoBrush) {
d->foregroundB...!= Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
4266 if (d->painterStateProtection)
d->painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4267 painter->save();
never executed: painter->save();
0
4268 painter->setBrushOrigin(0, 0);-
4269 painter->fillRect(rect, foregroundBrush());-
4270 if (d->painterStateProtection)
d->painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4271 painter->restore();
never executed: painter->restore();
0
4272 }
never executed: end of block
0
4273}
never executed: end of block
0
4274-
4275static void _q_paintItem(QGraphicsItem *item, QPainter *painter,-
4276 const QStyleOptionGraphicsItem *option, QWidget *widget,-
4277 bool useWindowOpacity, bool painterStateProtection)-
4278{-
4279 if (!item->isWidget()) {
!item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
4280 item->paint(painter, option, widget);-
4281 return;
never executed: return;
0
4282 }-
4283 QGraphicsWidget *widgetItem = static_cast<QGraphicsWidget *>(item);-
4284 QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(widgetItem);-
4285 const qreal windowOpacity = (proxy && proxy->widget() && useWindowOpacity)
proxyDescription
TRUEnever evaluated
FALSEnever evaluated
proxy->widget()Description
TRUEnever evaluated
FALSEnever evaluated
useWindowOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
4286 ? proxy->widget()->windowOpacity() : 1.0;-
4287 const qreal oldPainterOpacity = painter->opacity();-
4288-
4289 if (qFuzzyIsNull(windowOpacity))
qFuzzyIsNull(windowOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
4290 return;
never executed: return;
0
4291 // Set new painter opacity.-
4292 if (windowOpacity < 1.0)
windowOpacity < 1.0Description
TRUEnever evaluated
FALSEnever evaluated
0
4293 painter->setOpacity(oldPainterOpacity * windowOpacity);
never executed: painter->setOpacity(oldPainterOpacity * windowOpacity);
0
4294-
4295 // set layoutdirection on the painter-
4296 Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection();-
4297 painter->setLayoutDirection(widgetItem->layoutDirection());-
4298-
4299 if (widgetItem->isWindow() && widgetItem->windowType() != Qt::Popup && widgetItem->windowType() != Qt::ToolTip
widgetItem->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
widgetItem->wi...) != Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
widgetItem->wi...!= Qt::ToolTipDescription
TRUEnever evaluated
FALSEnever evaluated
0
4300 && !(widgetItem->windowFlags() & Qt::FramelessWindowHint)) {
!(widgetItem->...essWindowHint)Description
TRUEnever evaluated
FALSEnever evaluated
0
4301 if (painterStateProtection)
painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4302 painter->save();
never executed: painter->save();
0
4303 widgetItem->paintWindowFrame(painter, option, widget);-
4304 if (painterStateProtection)
painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4305 painter->restore();
never executed: painter->restore();
0
4306 } else if (widgetItem->autoFillBackground()) {
never executed: end of block
widgetItem->au...llBackground()Description
TRUEnever evaluated
FALSEnever evaluated
0
4307 painter->fillRect(option->exposedRect, widgetItem->palette().window());-
4308 }
never executed: end of block
0
4309-
4310 widgetItem->paint(painter, option, widget);-
4311-
4312 // Restore layoutdirection on the painter.-
4313 painter->setLayoutDirection(oldLayoutDirection);-
4314 // Restore painter opacity.-
4315 if (windowOpacity < 1.0)
windowOpacity < 1.0Description
TRUEnever evaluated
FALSEnever evaluated
0
4316 painter->setOpacity(oldPainterOpacity);
never executed: painter->setOpacity(oldPainterOpacity);
0
4317}
never executed: end of block
0
4318-
4319static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &pixmapExposed,-
4320 const QTransform &itemToPixmap, QPainter::RenderHints renderHints,-
4321 const QStyleOptionGraphicsItem *option, bool painterStateProtection)-
4322{-
4323 QPixmap subPix;-
4324 QPainter pixmapPainter;-
4325 QRect br = pixmapExposed.boundingRect();-
4326-
4327 // Don't use subpixmap if we get a full update.-
4328 if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) {
pixmapExposed.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
pixmapExposed.rectCount() == 1Description
TRUEnever evaluated
FALSEnever evaluated
br.contains(pix->rect())Description
TRUEnever evaluated
FALSEnever evaluated
0
4329 pix->fill(Qt::transparent);-
4330 pixmapPainter.begin(pix);-
4331 } else {
never executed: end of block
0
4332 subPix = QPixmap(br.size());-
4333 subPix.fill(Qt::transparent);-
4334 pixmapPainter.begin(&subPix);-
4335 pixmapPainter.translate(-br.topLeft());-
4336 if (!pixmapExposed.isEmpty()) {
!pixmapExposed.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4337 // Applied to subPix; paint is adjusted to the coordinate space is-
4338 // correct.-
4339 pixmapPainter.setClipRegion(pixmapExposed);-
4340 }
never executed: end of block
0
4341 }
never executed: end of block
0
4342-
4343 pixmapPainter.setRenderHints(pixmapPainter.renderHints(), false);-
4344 pixmapPainter.setRenderHints(renderHints, true);-
4345 pixmapPainter.setWorldTransform(itemToPixmap, true);-
4346-
4347 // Render.-
4348 _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection);-
4349 pixmapPainter.end();-
4350-
4351 if (!subPix.isNull()) {
!subPix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4352 // Blit the subpixmap into the main pixmap.-
4353 pixmapPainter.begin(pix);-
4354 pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);-
4355 pixmapPainter.setClipRegion(pixmapExposed);-
4356 pixmapPainter.drawPixmap(br.topLeft(), subPix);-
4357 pixmapPainter.end();-
4358 }
never executed: end of block
0
4359}
never executed: end of block
0
4360-
4361// Copied from qpaintengine_vg.cpp-
4362// Returns \c true for 90, 180, and 270 degree rotations.-
4363static inline bool transformIsSimple(const QTransform& transform)-
4364{-
4365 QTransform::TransformationType type = transform.type();-
4366 if (type <= QTransform::TxScale) {
type <= QTransform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4367 return true;
never executed: return true;
0
4368 } else if (type == QTransform::TxRotate) {
type == QTransform::TxRotateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4369 // Check for 90, and 270 degree rotations.-
4370 qreal m11 = transform.m11();-
4371 qreal m12 = transform.m12();-
4372 qreal m21 = transform.m21();-
4373 qreal m22 = transform.m22();-
4374 if (m11 == 0.0f && m22 == 0.0f) {
m11 == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
m22 == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
0
4375 if (m12 == 1.0f && m21 == -1.0f)
m12 == 1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
m21 == -1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
0
4376 return true; // 90 degrees.
never executed: return true;
0
4377 else if (m12 == -1.0f && m21 == 1.0f)
m12 == -1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
m21 == 1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
0
4378 return true; // 270 degrees.
never executed: return true;
0
4379 else if (m12 == -1.0f && m21 == -1.0f)
m12 == -1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
m21 == -1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
0
4380 return true; // 90 degrees inverted y.
never executed: return true;
0
4381 else if (m12 == 1.0f && m21 == 1.0f)
m12 == 1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
m21 == 1.0fDescription
TRUEnever evaluated
FALSEnever evaluated
0
4382 return true; // 270 degrees inverted y.
never executed: return true;
0
4383 }
never executed: end of block
0
4384 }
never executed: end of block
0
4385 return false;
never executed: return false;
0
4386}-
4387-
4388/*!-
4389 \internal-
4390-
4391 Draws items directly, or using cache.-
4392*/-
4393void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painter,-
4394 const QStyleOptionGraphicsItem *option, QWidget *widget,-
4395 bool painterStateProtection)-
4396{-
4397 QGraphicsItemPrivate *itemd = item->d_ptr.data();-
4398 QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode);-
4399-
4400 // Render directly, using no cache.-
4401 if (cacheMode == QGraphicsItem::NoCache
cacheMode == Q...sItem::NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
4402#ifdef Q_DEAD_CODE_FROM_QT4_X11-
4403 || !X11->use_xrender-
4404#endif-
4405 ) {-
4406 _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection);-
4407 return;
never executed: return;
0
4408 }-
4409-
4410 const qreal oldPainterOpacity = painter->opacity();-
4411 qreal newPainterOpacity = oldPainterOpacity;-
4412 QGraphicsProxyWidget *proxy = item->isWidget() ? qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(item)) : 0;
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
4413 if (proxy && proxy->widget()) {
proxyDescription
TRUEnever evaluated
FALSEnever evaluated
proxy->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
4414 const qreal windowOpacity = proxy->widget()->windowOpacity();-
4415 if (windowOpacity < 1.0)
windowOpacity < 1.0Description
TRUEnever evaluated
FALSEnever evaluated
0
4416 newPainterOpacity *= windowOpacity;
never executed: newPainterOpacity *= windowOpacity;
0
4417 }
never executed: end of block
0
4418-
4419 // Item's (local) bounding rect-
4420 QRectF brect = item->boundingRect();-
4421 QRectF adjustedBrect(brect);-
4422 _q_adjustRect(&adjustedBrect);-
4423 if (adjustedBrect.isEmpty())
adjustedBrect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4424 return;
never executed: return;
0
4425-
4426 // Fetch the off-screen transparent buffer and exposed area info.-
4427 QPixmapCache::Key pixmapKey;-
4428 QPixmap pix;-
4429 bool pixmapFound;-
4430 QGraphicsItemCache *itemCache = itemd->extraItemCache();-
4431 if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
cacheMode == Q...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
4432 pixmapKey = itemCache->key;-
4433 } else {
never executed: end of block
0
4434 pixmapKey = itemCache->deviceData.value(widget).key;-
4435 }
never executed: end of block
0
4436-
4437 // Find pixmap in cache.-
4438 pixmapFound = QPixmapCache::find(pixmapKey, &pix);-
4439-
4440 // Render using item coordinate cache mode.-
4441 if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
cacheMode == Q...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
4442 QSize pixmapSize;-
4443 bool fixedCacheSize = false;-
4444 QRect br = brect.toAlignedRect();-
4445 if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
(fixedCacheSiz...ize.isValid())Description
TRUEnever evaluated
FALSEnever evaluated
0
4446 pixmapSize = itemCache->fixedSize;-
4447 } else {
never executed: end of block
0
4448 pixmapSize = br.size();-
4449 }
never executed: end of block
0
4450-
4451 // Create or recreate the pixmap.-
4452 int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
itemCache->fixedSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
4453 QSize adjustSize(adjust*2, adjust*2);-
4454 br.adjust(-adjust, -adjust, adjust, adjust);-
4455 if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
pix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!fixedCacheSizeDescription
TRUEnever evaluated
FALSEnever evaluated
(pixmapSize + ... != pix.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4456 pix = QPixmap(pixmapSize + adjustSize);-
4457 itemCache->boundingRect = br;-
4458 itemCache->exposed.clear();-
4459 itemCache->allExposed = true;-
4460 } else if (itemCache->boundingRect != br) {
never executed: end of block
itemCache->boundingRect != brDescription
TRUEnever evaluated
FALSEnever evaluated
0
4461 itemCache->boundingRect = br;-
4462 itemCache->exposed.clear();-
4463 itemCache->allExposed = true;-
4464 }
never executed: end of block
0
4465-
4466 // Redraw any newly exposed areas.-
4467 if (itemCache->allExposed || !itemCache->exposed.isEmpty()) {
itemCache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
!itemCache->exposed.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4468-
4469 //We know that we will modify the pixmap, removing it from the cache-
4470 //will detach the one we have and avoid a deep copy-
4471 if (pixmapFound)
pixmapFoundDescription
TRUEnever evaluated
FALSEnever evaluated
0
4472 QPixmapCache::remove(pixmapKey);
never executed: QPixmapCache::remove(pixmapKey);
0
4473-
4474 // Fit the item's bounding rect into the pixmap's coordinates.-
4475 QTransform itemToPixmap;-
4476 if (fixedCacheSize) {
fixedCacheSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4477 const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());-
4478 itemToPixmap.scale(scale.x(), scale.y());-
4479 }
never executed: end of block
0
4480 itemToPixmap.translate(-br.x(), -br.y());-
4481-
4482 // Generate the item's exposedRect and map its list of expose-
4483 // rects to device coordinates.-
4484 styleOptionTmp = *option;-
4485 QRegion pixmapExposed;-
4486 QRectF exposedRect;-
4487 if (!itemCache->allExposed) {
!itemCache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4488 for (int i = 0; i < itemCache->exposed.size(); ++i) {
i < itemCache->exposed.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4489 QRectF r = itemCache->exposed.at(i);-
4490 exposedRect |= r;-
4491 pixmapExposed += itemToPixmap.mapRect(r).toAlignedRect();-
4492 }
never executed: end of block
0
4493 } else {
never executed: end of block
0
4494 exposedRect = brect;-
4495 }
never executed: end of block
0
4496 styleOptionTmp.exposedRect = exposedRect;-
4497-
4498 // Render.-
4499 _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),-
4500 &styleOptionTmp, painterStateProtection);-
4501-
4502 // insert this pixmap into the cache.-
4503 itemCache->key = QPixmapCache::insert(pix);-
4504-
4505 // Reset expose data.-
4506 itemCache->allExposed = false;-
4507 itemCache->exposed.clear();-
4508 }
never executed: end of block
0
4509-
4510 // Redraw the exposed area using the transformed painter. Depending on-
4511 // the hardware, this may be a server-side operation, or an expensive-
4512 // qpixmap-image-transform-pixmap roundtrip.-
4513 if (newPainterOpacity != oldPainterOpacity) {
newPainterOpac...PainterOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
4514 painter->setOpacity(newPainterOpacity);-
4515 painter->drawPixmap(br.topLeft(), pix);-
4516 painter->setOpacity(oldPainterOpacity);-
4517 } else {
never executed: end of block
0
4518 painter->drawPixmap(br.topLeft(), pix);-
4519 }
never executed: end of block
0
4520 return;
never executed: return;
0
4521 }-
4522-
4523 // Render using device coordinate cache mode.-
4524 if (cacheMode == QGraphicsItem::DeviceCoordinateCache) {
cacheMode == Q...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
4525 // Find the item's bounds in device coordinates.-
4526 QRectF deviceBounds = painter->worldTransform().mapRect(brect);-
4527 QRect deviceRect = deviceBounds.toRect().adjusted(-1, -1, 1, 1);-
4528 if (deviceRect.isEmpty())
deviceRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4529 return;
never executed: return;
0
4530 QRect viewRect = widget ? widget->rect() : QRect();
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
4531 if (widget && !viewRect.intersects(deviceRect))
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
!viewRect.inte...ts(deviceRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
4532 return;
never executed: return;
0
4533-
4534 // Resort to direct rendering if the device rect exceeds the-
4535 // (optional) maximum bounds. (QGraphicsSvgItem uses this).-
4536 QSize maximumCacheSize =-
4537 itemd->extra(QGraphicsItemPrivate::ExtraMaxDeviceCoordCacheSize).toSize();-
4538 if (!maximumCacheSize.isEmpty()
!maximumCacheSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4539 && (deviceRect.width() > maximumCacheSize.width()
deviceRect.wid...heSize.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
4540 || deviceRect.height() > maximumCacheSize.height())) {
deviceRect.hei...eSize.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
4541 _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget,-
4542 oldPainterOpacity != newPainterOpacity, painterStateProtection);-
4543 return;
never executed: return;
0
4544 }-
4545-
4546 // Create or reuse offscreen pixmap, possibly scroll/blit from the old one.-
4547 // If the world transform is rotated we always recreate the cache to avoid-
4548 // wrong blending.-
4549 bool pixModified = false;-
4550 QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget];-
4551 bool invertable = true;-
4552 QTransform diff = deviceData->lastTransform.inverted(&invertable);-
4553 if (invertable)
invertableDescription
TRUEnever evaluated
FALSEnever evaluated
0
4554 diff *= painter->worldTransform();
never executed: diff *= painter->worldTransform();
0
4555 deviceData->lastTransform = painter->worldTransform();-
4556 bool allowPartialCacheExposure = false;-
4557 bool simpleTransform = invertable && diff.type() <= QTransform::TxTranslate
invertableDescription
TRUEnever evaluated
FALSEnever evaluated
diff.type() <=...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4558 && transformIsSimple(painter->worldTransform());
transformIsSim...ldTransform())Description
TRUEnever evaluated
FALSEnever evaluated
0
4559 if (!simpleTransform) {
!simpleTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4560 pixModified = true;-
4561 itemCache->allExposed = true;-
4562 itemCache->exposed.clear();-
4563 deviceData->cacheIndent = QPoint();-
4564 pix = QPixmap();-
4565 } else if (!viewRect.isNull()) {
never executed: end of block
!viewRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4566 allowPartialCacheExposure = deviceData->cacheIndent != QPoint();-
4567 }
never executed: end of block
0
4568-
4569 // Allow partial cache exposure if the device rect isn't fully contained and-
4570 // deviceRect is 20% taller or wider than the viewRect.-
4571 if (!allowPartialCacheExposure && !viewRect.isNull() && !viewRect.contains(deviceRect)) {
!allowPartialCacheExposureDescription
TRUEnever evaluated
FALSEnever evaluated
!viewRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!viewRect.contains(deviceRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
4572 allowPartialCacheExposure = (viewRect.width() * 1.2 < deviceRect.width())
(viewRect.widt...eRect.width())Description
TRUEnever evaluated
FALSEnever evaluated
0
4573 || (viewRect.height() * 1.2 < deviceRect.height());
(viewRect.heig...Rect.height())Description
TRUEnever evaluated
FALSEnever evaluated
0
4574 }
never executed: end of block
0
4575-
4576 QRegion scrollExposure;-
4577 if (allowPartialCacheExposure) {
allowPartialCacheExposureDescription
TRUEnever evaluated
FALSEnever evaluated
0
4578 // Part of pixmap is drawn. Either device contains viewrect (big-
4579 // item covers whole screen) or parts of device are outside the-
4580 // viewport. In either case the device rect must be the intersect-
4581 // between the two.-
4582 int dx = deviceRect.left() < viewRect.left() ? viewRect.left() - deviceRect.left() : 0;
deviceRect.lef...iewRect.left()Description
TRUEnever evaluated
FALSEnever evaluated
0
4583 int dy = deviceRect.top() < viewRect.top() ? viewRect.top() - deviceRect.top() : 0;
deviceRect.top...viewRect.top()Description
TRUEnever evaluated
FALSEnever evaluated
0
4584 QPoint newCacheIndent(dx, dy);-
4585 deviceRect &= viewRect;-
4586-
4587 if (pix.isNull()) {
pix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4588 deviceData->cacheIndent = QPoint();-
4589 itemCache->allExposed = true;-
4590 itemCache->exposed.clear();-
4591 pixModified = true;-
4592 }
never executed: end of block
0
4593-
4594 // Copy / "scroll" the old pixmap onto the new ole and calculate-
4595 // scrolled exposure.-
4596 if (newCacheIndent != deviceData->cacheIndent || deviceRect.size() != pix.size()) {
newCacheIndent...a->cacheIndentDescription
TRUEnever evaluated
FALSEnever evaluated
deviceRect.siz... != pix.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4597 QPoint diff = newCacheIndent - deviceData->cacheIndent;-
4598 QPixmap newPix(deviceRect.size());-
4599 // ### Investigate removing this fill (test with Plasma and-
4600 // graphicssystem raster).-
4601 newPix.fill(Qt::transparent);-
4602 if (!pix.isNull()) {
!pix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4603 QPainter newPixPainter(&newPix);-
4604 newPixPainter.drawPixmap(-diff, pix);-
4605 newPixPainter.end();-
4606 }
never executed: end of block
0
4607 QRegion exposed;-
4608 exposed += newPix.rect();-
4609 if (!pix.isNull())
!pix.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4610 exposed -= QRect(-diff, pix.size());
never executed: exposed -= QRect(-diff, pix.size());
0
4611 scrollExposure = exposed;-
4612-
4613 pix = newPix;-
4614 pixModified = true;-
4615 }
never executed: end of block
0
4616 deviceData->cacheIndent = newCacheIndent;-
4617 } else {
never executed: end of block
0
4618 // Full pixmap is drawn.-
4619 deviceData->cacheIndent = QPoint();-
4620-
4621 // Auto-adjust the pixmap size.-
4622 if (deviceRect.size() != pix.size()) {
deviceRect.siz... != pix.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4623 // exposed needs to cover the whole pixmap-
4624 pix = QPixmap(deviceRect.size());-
4625 pixModified = true;-
4626 itemCache->allExposed = true;-
4627 itemCache->exposed.clear();-
4628 }
never executed: end of block
0
4629 }
never executed: end of block
0
4630-
4631 // Check for newly invalidated areas.-
4632 if (itemCache->allExposed || !itemCache->exposed.isEmpty() || !scrollExposure.isEmpty()) {
itemCache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
!itemCache->exposed.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!scrollExposure.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4633 //We know that we will modify the pixmap, removing it from the cache-
4634 //will detach the one we have and avoid a deep copy-
4635 if (pixmapFound)
pixmapFoundDescription
TRUEnever evaluated
FALSEnever evaluated
0
4636 QPixmapCache::remove(pixmapKey);
never executed: QPixmapCache::remove(pixmapKey);
0
4637-
4638 // Construct an item-to-pixmap transform.-
4639 QPointF p = deviceRect.topLeft();-
4640 QTransform itemToPixmap = painter->worldTransform();-
4641 if (!p.isNull())
!p.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
4642 itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
never executed: itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
0
4643-
4644 // Map the item's logical expose to pixmap coordinates.-
4645 QRegion pixmapExposed = scrollExposure;-
4646 if (!itemCache->allExposed) {
!itemCache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4647 const QVector<QRectF> &exposed = itemCache->exposed;-
4648 for (int i = 0; i < exposed.size(); ++i)
i < exposed.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4649 pixmapExposed += itemToPixmap.mapRect(exposed.at(i)).toRect().adjusted(-1, -1, 1, 1);
never executed: pixmapExposed += itemToPixmap.mapRect(exposed.at(i)).toRect().adjusted(-1, -1, 1, 1);
0
4650 }
never executed: end of block
0
4651-
4652 // Calculate the style option's exposedRect.-
4653 QRectF br;-
4654 if (itemCache->allExposed) {
itemCache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4655 br = item->boundingRect();-
4656 } else {
never executed: end of block
0
4657 const QVector<QRectF> &exposed = itemCache->exposed;-
4658 for (int i = 0; i < exposed.size(); ++i)
i < exposed.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4659 br |= exposed.at(i);
never executed: br |= exposed.at(i);
0
4660 QTransform pixmapToItem = itemToPixmap.inverted();-
4661 const auto rects = scrollExposure.rects();-
4662 for (const QRect &r : rects)-
4663 br |= pixmapToItem.mapRect(r);
never executed: br |= pixmapToItem.mapRect(r);
0
4664 }
never executed: end of block
0
4665 styleOptionTmp = *option;-
4666 styleOptionTmp.exposedRect = br.adjusted(-1, -1, 1, 1);-
4667-
4668 // Render the exposed areas.-
4669 _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),-
4670 &styleOptionTmp, painterStateProtection);-
4671-
4672 // Reset expose data.-
4673 pixModified = true;-
4674 itemCache->allExposed = false;-
4675 itemCache->exposed.clear();-
4676 }
never executed: end of block
0
4677-
4678 if (pixModified) {
pixModifiedDescription
TRUEnever evaluated
FALSEnever evaluated
0
4679 // Insert this pixmap into the cache.-
4680 deviceData->key = QPixmapCache::insert(pix);-
4681 }
never executed: end of block
0
4682-
4683 // Redraw the exposed area using an untransformed painter. This-
4684 // effectively becomes a bitblit that does not transform the cache.-
4685 QTransform restoreTransform = painter->worldTransform();-
4686 painter->setWorldTransform(QTransform());-
4687 if (newPainterOpacity != oldPainterOpacity) {
newPainterOpac...PainterOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
4688 painter->setOpacity(newPainterOpacity);-
4689 painter->drawPixmap(deviceRect.topLeft(), pix);-
4690 painter->setOpacity(oldPainterOpacity);-
4691 } else {
never executed: end of block
0
4692 painter->drawPixmap(deviceRect.topLeft(), pix);-
4693 }
never executed: end of block
0
4694 painter->setWorldTransform(restoreTransform);-
4695 return;
never executed: return;
0
4696 }-
4697}
never executed: end of block
0
4698-
4699void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const viewTransform,-
4700 QRegion *exposedRegion, QWidget *widget)-
4701{-
4702 // Make sure we don't have unpolished items before we draw.-
4703 if (!unpolishedItems.isEmpty())
!unpolishedItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4704 _q_polishItems();
never executed: _q_polishItems();
0
4705-
4706 updateAll = false;-
4707 QRectF exposedSceneRect;-
4708 if (exposedRegion && indexMethod != QGraphicsScene::NoIndex) {
exposedRegionDescription
TRUEnever evaluated
FALSEnever evaluated
indexMethod !=...Scene::NoIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4709 exposedSceneRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1);-
4710 if (viewTransform)
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4711 exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect);
never executed: exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect);
0
4712 }
never executed: end of block
0
4713 const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder);-
4714 for (int i = 0; i < tli.size(); ++i)
i < tli.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4715 drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget);
never executed: drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget);
0
4716}
never executed: end of block
0
4717-
4718void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter,-
4719 const QTransform *const viewTransform,-
4720 QRegion *exposedRegion, QWidget *widget,-
4721 qreal parentOpacity, const QTransform *const effectTransform)-
4722{-
4723 Q_ASSERT(item);-
4724-
4725 if (!item->d_ptr->visible)
!item->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4726 return;
never executed: return;
0
4727-
4728 const bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);-
4729 const bool itemHasChildren = !item->d_ptr->children.isEmpty();-
4730 if (!itemHasContents && !itemHasChildren)
!itemHasContentsDescription
TRUEnever evaluated
FALSEnever evaluated
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
4731 return; // Item has neither contents nor children!(?)
never executed: return;
0
4732-
4733 const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);-
4734 const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);-
4735 if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity()))
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->c...mbineOpacity()Description
TRUEnever evaluated
FALSEnever evaluated
0
4736 return;
never executed: return;
0
4737-
4738 QTransform transform(Qt::Uninitialized);-
4739 QTransform *transformPtr = 0;-
4740 bool translateOnlyTransform = false;-
4741#define ENSURE_TRANSFORM_PTR \-
4742 if (!transformPtr) { \-
4743 Q_ASSERT(!itemIsUntransformable); \-
4744 if (viewTransform) { \-
4745 transform = item->d_ptr->sceneTransform; \-
4746 transform *= *viewTransform; \-
4747 transformPtr = &transform; \-
4748 } else { \-
4749 transformPtr = &item->d_ptr->sceneTransform; \-
4750 translateOnlyTransform = item->d_ptr->sceneTransformTranslateOnly; \-
4751 } \-
4752 }-
4753-
4754 // Update the item's scene transform if the item is transformable;-
4755 // otherwise calculate the full transform,-
4756 bool wasDirtyParentSceneTransform = false;-
4757 const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();-
4758 if (itemIsUntransformable) {
itemIsUntransformableDescription
TRUEnever evaluated
FALSEnever evaluated
0
4759 transform = item->deviceTransform(viewTransform ? *viewTransform : QTransform());-
4760 transformPtr = &transform;-
4761 } else if (item->d_ptr->dirtySceneTransform) {
never executed: end of block
item->d_ptr->d...SceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4762 item->d_ptr->updateSceneTransformFromParent();-
4763 Q_ASSERT(!item->d_ptr->dirtySceneTransform);-
4764 wasDirtyParentSceneTransform = true;-
4765 }
never executed: end of block
0
4766-
4767 const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape
item->d_ptr->f...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4768 || item->d_ptr->flags & QGraphicsItem::ItemContainsChildrenInShape);
item->d_ptr->f...hildrenInShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4769 bool drawItem = itemHasContents && !itemIsFullyTransparent;
itemHasContentsDescription
TRUEnever evaluated
FALSEnever evaluated
!itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4770 if (drawItem || minimumRenderSize > 0.0) {
drawItemDescription
TRUEnever evaluated
FALSEnever evaluated
minimumRenderSize > 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
4771 const QRectF brect = adjustedItemEffectiveBoundingRect(item);-
4772 ENSURE_TRANSFORM_PTR
never executed: end of block
never executed: end of block
!transformPtrDescription
TRUEnever evaluated
FALSEnever evaluated
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4773 QRectF preciseViewBoundingRect = translateOnlyTransform ? brect.translated(transformPtr->dx(), transformPtr->dy())
translateOnlyTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4774 : transformPtr->mapRect(brect);-
4775-
4776 bool itemIsTooSmallToRender = false;-
4777 if (minimumRenderSize > 0.0
minimumRenderSize > 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
4778 && (preciseViewBoundingRect.width() < minimumRenderSize
preciseViewBou...imumRenderSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4779 || preciseViewBoundingRect.height() < minimumRenderSize)) {
preciseViewBou...imumRenderSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4780 itemIsTooSmallToRender = true;-
4781 drawItem = false;-
4782 }
never executed: end of block
0
4783-
4784 bool itemIsOutsideVisibleRect = false;-
4785 if (drawItem) {
drawItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
4786 QRect viewBoundingRect = preciseViewBoundingRect.toAlignedRect();-
4787 viewBoundingRect.adjust(-int(rectAdjust), -int(rectAdjust), rectAdjust, rectAdjust);-
4788 if (widget)
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
4789 item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
never executed: item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
0
4790 drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect)
exposedRegionDescription
TRUEnever evaluated
FALSEnever evaluated
0
4791 : !viewBoundingRect.normalized().isEmpty();-
4792 itemIsOutsideVisibleRect = !drawItem;-
4793 }
never executed: end of block
0
4794-
4795 if (itemIsTooSmallToRender || itemIsOutsideVisibleRect) {
itemIsTooSmallToRenderDescription
TRUEnever evaluated
FALSEnever evaluated
itemIsOutsideVisibleRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4796 // We cannot simply use !drawItem here. If we did it is possible-
4797 // to enter the outter if statement with drawItem == false and minimumRenderSize > 0-
4798 // and finally end up inside this inner if, even though none of the above two-
4799 // conditions are met. In that case we should not return from this function-
4800 // but call draw() instead.-
4801 if (!itemHasChildren)
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
4802 return;
never executed: return;
0
4803 if (itemClipsChildrenToShape) {
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4804 if (wasDirtyParentSceneTransform)
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4805 item->d_ptr->invalidateChildrenSceneTransform();
never executed: item->d_ptr->invalidateChildrenSceneTransform();
0
4806 return;
never executed: return;
0
4807 }-
4808 }
never executed: end of block
0
4809 } // else we know for sure this item has children we must process.
never executed: end of block
0
4810-
4811 if (itemHasChildren && itemClipsChildrenToShape)
itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4812 ENSURE_TRANSFORM_PTR;
never executed: end of block
never executed: end of block
!transformPtrDescription
TRUEnever evaluated
FALSEnever evaluated
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4813-
4814#ifndef QT_NO_GRAPHICSEFFECT-
4815 if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) {
item->d_ptr->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->g...t->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
4816 ENSURE_TRANSFORM_PTR;
never executed: end of block
never executed: end of block
!transformPtrDescription
TRUEnever evaluated
FALSEnever evaluated
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4817 QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp,-
4818 painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent);-
4819 QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source;-
4820 QGraphicsItemEffectSourcePrivate *sourced = static_cast<QGraphicsItemEffectSourcePrivate *>-
4821 (source->d_func());-
4822 sourced->info = &info;-
4823 const QTransform restoreTransform = painter->worldTransform();-
4824 if (effectTransform)
effectTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4825 painter->setWorldTransform(*transformPtr * *effectTransform);
never executed: painter->setWorldTransform(*transformPtr * *effectTransform);
0
4826 else-
4827 painter->setWorldTransform(*transformPtr);
never executed: painter->setWorldTransform(*transformPtr);
0
4828 painter->setOpacity(opacity);-
4829-
4830 if (sourced->currentCachedSystem() != Qt::LogicalCoordinates
sourced->curre...calCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4831 && sourced->lastEffectTransform != painter->worldTransform())
sourced->lastE...rldTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
4832 {-
4833 if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate
sourced->lastE...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4834 && painter->worldTransform().type() <= QTransform::TxTranslate)
painter->world...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
4835 {-
4836 QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates);-
4837 QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect);-
4838-
4839 sourced->setCachedOffset(effectRect.topLeft());-
4840 } else {
never executed: end of block
0
4841 sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);-
4842 }
never executed: end of block
0
4843-
4844 sourced->lastEffectTransform = painter->worldTransform();-
4845 }
never executed: end of block
0
4846-
4847 item->d_ptr->graphicsEffect->draw(painter);-
4848 painter->setWorldTransform(restoreTransform);-
4849 sourced->info = 0;-
4850 } else
never executed: end of block
0
4851#endif //QT_NO_GRAPHICSEFFECT-
4852 {-
4853 draw(item, painter, viewTransform, transformPtr, exposedRegion, widget, opacity,-
4854 effectTransform, wasDirtyParentSceneTransform, drawItem);-
4855 }
never executed: end of block
0
4856}-
4857-
4858static inline void setClip(QPainter *painter, QGraphicsItem *item)-
4859{-
4860 painter->save();-
4861 QRectF clipRect;-
4862 const QPainterPath clipPath(item->shape());-
4863 if (QPathClipper::pathToRect(clipPath, &clipRect))
QPathClipper::...th, &clipRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
4864 painter->setClipRect(clipRect, Qt::IntersectClip);
never executed: painter->setClipRect(clipRect, Qt::IntersectClip);
0
4865 else-
4866 painter->setClipPath(clipPath, Qt::IntersectClip);
never executed: painter->setClipPath(clipPath, Qt::IntersectClip);
0
4867}-
4868-
4869static inline void setWorldTransform(QPainter *painter, const QTransform *const transformPtr,-
4870 const QTransform *effectTransform)-
4871{-
4872 Q_ASSERT(transformPtr);-
4873 if (effectTransform)
effectTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4874 painter->setWorldTransform(*transformPtr * *effectTransform);
never executed: painter->setWorldTransform(*transformPtr * *effectTransform);
0
4875 else-
4876 painter->setWorldTransform(*transformPtr);
never executed: painter->setWorldTransform(*transformPtr);
0
4877}-
4878-
4879void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const QTransform *const viewTransform,-
4880 const QTransform *const transformPtr, QRegion *exposedRegion, QWidget *widget,-
4881 qreal opacity, const QTransform *effectTransform,-
4882 bool wasDirtyParentSceneTransform, bool drawItem)-
4883{-
4884 const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);-
4885 const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);-
4886 const bool itemHasChildren = !item->d_ptr->children.isEmpty();-
4887 bool setChildClip = itemClipsChildrenToShape;-
4888 bool itemHasChildrenStackedBehind = false;-
4889-
4890 int i = 0;-
4891 if (itemHasChildren) {
itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
4892 if (itemClipsChildrenToShape)
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4893 setWorldTransform(painter, transformPtr, effectTransform);
never executed: setWorldTransform(painter, transformPtr, effectTransform);
0
4894-
4895 item->d_ptr->ensureSortedChildren();-
4896 // Items with the 'ItemStacksBehindParent' flag are put in front of the list-
4897 // so all we have to do is to check the first item.-
4898 itemHasChildrenStackedBehind = (item->d_ptr->children.at(0)->d_ptr->flags-
4899 & QGraphicsItem::ItemStacksBehindParent);-
4900-
4901 if (itemHasChildrenStackedBehind) {
itemHasChildrenStackedBehindDescription
TRUEnever evaluated
FALSEnever evaluated
0
4902 if (itemClipsChildrenToShape) {
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4903 setClip(painter, item);-
4904 setChildClip = false;-
4905 }
never executed: end of block
0
4906-
4907 // Draw children behind-
4908 for (i = 0; i < item->d_ptr->children.size(); ++i) {
i < item->d_pt...hildren.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4909 QGraphicsItem *child = item->d_ptr->children.at(i);-
4910 if (wasDirtyParentSceneTransform)
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4911 child->d_ptr->dirtySceneTransform = 1;
never executed: child->d_ptr->dirtySceneTransform = 1;
0
4912 if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent))
!(child->d_ptr...sBehindParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
4913 break;
never executed: break;
0
4914 if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!(child->d_ptr...ParentOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
4915 continue;
never executed: continue;
0
4916 drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);-
4917 }
never executed: end of block
0
4918 }
never executed: end of block
0
4919 }
never executed: end of block
0
4920-
4921 // Draw item-
4922 if (drawItem) {
drawItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
4923 Q_ASSERT(!itemIsFullyTransparent);-
4924 Q_ASSERT(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents));-
4925 Q_ASSERT(transformPtr);-
4926 item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion-
4927 ? *exposedRegion : QRegion(), exposedRegion == 0);-
4928-
4929 const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape;-
4930 bool restorePainterClip = false;-
4931-
4932 if (!itemHasChildren || !itemClipsChildrenToShape) {
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
!itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4933 // Item does not have children or clip children to shape.-
4934 setWorldTransform(painter, transformPtr, effectTransform);-
4935 if ((restorePainterClip = itemClipsToShape))
(restorePainte...mClipsToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
4936 setClip(painter, item);
never executed: setClip(painter, item);
0
4937 } else if (itemHasChildrenStackedBehind){
never executed: end of block
itemHasChildrenStackedBehindDescription
TRUEnever evaluated
FALSEnever evaluated
0
4938 // Item clips children to shape and has children stacked behind, which means-
4939 // the painter is already clipped to the item's shape.-
4940 if (itemClipsToShape) {
itemClipsToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4941 // The clip is already correct. Ensure correct world transform.-
4942 setWorldTransform(painter, transformPtr, effectTransform);-
4943 } else {
never executed: end of block
0
4944 // Remove clip (this also ensures correct world transform).-
4945 painter->restore();-
4946 setChildClip = true;-
4947 }
never executed: end of block
0
4948 } else if (itemClipsToShape) {
itemClipsToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4949 // Item clips children and itself to shape. It does not have hildren stacked-
4950 // behind, which means the clip has not yet been set. We set it now and re-use it-
4951 // for the children.-
4952 setClip(painter, item);-
4953 setChildClip = false;-
4954 }
never executed: end of block
0
4955-
4956 if (painterStateProtection && !restorePainterClip)
painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
!restorePainterClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
4957 painter->save();
never executed: painter->save();
0
4958-
4959 painter->setOpacity(opacity);-
4960 if (!item->d_ptr->cacheMode && !item->d_ptr->isWidget)
!item->d_ptr->cacheModeDescription
TRUEnever evaluated
FALSEnever evaluated
!item->d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
4961 item->paint(painter, &styleOptionTmp, widget);
never executed: item->paint(painter, &styleOptionTmp, widget);
0
4962 else-
4963 drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
never executed: drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
0
4964-
4965 if (painterStateProtection || restorePainterClip)
painterStateProtectionDescription
TRUEnever evaluated
FALSEnever evaluated
restorePainterClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
4966 painter->restore();
never executed: painter->restore();
0
4967-
4968 static int drawRect = qEnvironmentVariableIntValue("QT_DRAW_SCENE_ITEM_RECTS");-
4969 if (drawRect) {
drawRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4970 QPen oldPen = painter->pen();-
4971 QBrush oldBrush = painter->brush();-
4972 quintptr ptr = reinterpret_cast<quintptr>(item);-
4973 const QColor color = QColor::fromHsv(ptr % 255, 255, 255);-
4974 painter->setPen(color);-
4975 painter->setBrush(Qt::NoBrush);-
4976 painter->drawRect(adjustedItemBoundingRect(item));-
4977 painter->setPen(oldPen);-
4978 painter->setBrush(oldBrush);-
4979 }
never executed: end of block
0
4980 }
never executed: end of block
0
4981-
4982 // Draw children in front-
4983 if (itemHasChildren) {
itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
4984 if (setChildClip)
setChildClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
4985 setClip(painter, item);
never executed: setClip(painter, item);
0
4986-
4987 for (; i < item->d_ptr->children.size(); ++i) {
i < item->d_pt...hildren.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4988 QGraphicsItem *child = item->d_ptr->children.at(i);-
4989 if (wasDirtyParentSceneTransform)
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4990 child->d_ptr->dirtySceneTransform = 1;
never executed: child->d_ptr->dirtySceneTransform = 1;
0
4991 if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!(child->d_ptr...ParentOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
4992 continue;
never executed: continue;
0
4993 drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);-
4994 }
never executed: end of block
0
4995-
4996 // Restore child clip-
4997 if (itemClipsChildrenToShape)
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4998 painter->restore();
never executed: painter->restore();
0
4999 }
never executed: end of block
0
5000}
never executed: end of block
0
5001-
5002void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren,-
5003 bool force, bool ignoreOpacity, bool removingItemFromScene,-
5004 bool updateBoundingRect)-
5005{-
5006 Q_ASSERT(item);-
5007 if (updateAll)
updateAllDescription
TRUEnever evaluated
FALSEnever evaluated
0
5008 return;
never executed: return;
0
5009-
5010 if (removingItemFromScene && !ignoreOpacity && !item->d_ptr->ignoreOpacity) {
removingItemFromSceneDescription
TRUEnever evaluated
FALSEnever evaluated
!ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
!item->d_ptr->ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5011 // If any of the item's ancestors ignore opacity, it means that the opacity-
5012 // was set to 0 (and the update request has not yet been processed). That-
5013 // also means that we have to ignore the opacity for the item itself; otherwise-
5014 // things like: parent->setOpacity(0); scene->removeItem(child) won't work.-
5015 // Note that we only do this when removing items from the scene. In all other-
5016 // cases the ignoreOpacity bit propagates properly in processDirtyItems, but-
5017 // since the item is removed immediately it won't be processed there.-
5018 QGraphicsItem *p = item->d_ptr->parent;-
5019 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
5020 if (p->d_ptr->ignoreOpacity) {
p->d_ptr->ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5021 item->d_ptr->ignoreOpacity = true;-
5022 break;
never executed: break;
0
5023 }-
5024 p = p->d_ptr->parent;-
5025 }
never executed: end of block
0
5026 }
never executed: end of block
0
5027-
5028 if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force,
item->d_ptr->d...ignoreOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5029 /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren,
item->d_ptr->d...ignoreOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5030 /*ignoreOpacity=*/ignoreOpacity)) {
item->d_ptr->d...ignoreOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5031 if (item->d_ptr->dirty) {
item->d_ptr->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
5032 // The item is already marked as dirty and will be processed later. However,-
5033 // we have to make sure ignoreVisible and ignoreOpacity are set properly;-
5034 // otherwise things like: item->update(); item->hide() (force is now true)-
5035 // won't work as expected.-
5036 if (force)
forceDescription
TRUEnever evaluated
FALSEnever evaluated
0
5037 item->d_ptr->ignoreVisible = 1;
never executed: item->d_ptr->ignoreVisible = 1;
0
5038 if (ignoreOpacity)
ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5039 item->d_ptr->ignoreOpacity = 1;
never executed: item->d_ptr->ignoreOpacity = 1;
0
5040 }
never executed: end of block
0
5041 return;
never executed: return;
0
5042 }-
5043-
5044 const bool fullItemUpdate = rect.isNull();-
5045 if (!fullItemUpdate && rect.isEmpty())
!fullItemUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5046 return;
never executed: return;
0
5047-
5048 if (!processDirtyItemsEmitted) {
!processDirtyItemsEmittedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5049 QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex);-
5050 method.invoke(q_ptr, Qt::QueuedConnection);-
5051// QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection);-
5052 processDirtyItemsEmitted = true;-
5053 }
never executed: end of block
0
5054-
5055 if (removingItemFromScene) {
removingItemFromSceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5056 // Note that this function can be called from the item's destructor, so-
5057 // do NOT call any virtual functions on it within this block.-
5058 if (isSignalConnected(changedSignalIndex) || views.isEmpty()) {
isSignalConnec...edSignalIndex)Description
TRUEnever evaluated
FALSEnever evaluated
views.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5059 // This block of code is kept for compatibility. Since 4.5, by default-
5060 // QGraphicsView does not connect the signal and we use the below-
5061 // method of delivering updates.-
5062 q_func()->update();-
5063 return;
never executed: return;
0
5064 }-
5065-
5066 for (int i = 0; i < views.size(); ++i) {
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5067 QGraphicsViewPrivate *viewPrivate = views.at(i)->d_func();-
5068 QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport);-
5069 rect.translate(viewPrivate->dirtyScrollOffset);-
5070 viewPrivate->updateRect(rect);-
5071 }
never executed: end of block
0
5072 return;
never executed: return;
0
5073 }-
5074-
5075 bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents;-
5076 if (!hasNoContents) {
!hasNoContentsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5077 item->d_ptr->dirty = 1;-
5078 if (fullItemUpdate)
fullItemUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
5079 item->d_ptr->fullUpdatePending = 1;
never executed: item->d_ptr->fullUpdatePending = 1;
0
5080 else if (!item->d_ptr->fullUpdatePending)
!item->d_ptr->...lUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5081 item->d_ptr->needsRepaint |= rect;
never executed: item->d_ptr->needsRepaint |= rect;
0
5082 } else if (item->d_ptr->graphicsEffect) {
never executed: end of block
item->d_ptr->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5083 invalidateChildren = true;-
5084 }
never executed: end of block
0
5085-
5086 if (invalidateChildren) {
invalidateChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5087 item->d_ptr->allChildrenDirty = 1;-
5088 item->d_ptr->dirtyChildren = 1;-
5089 }
never executed: end of block
0
5090-
5091 if (force)
forceDescription
TRUEnever evaluated
FALSEnever evaluated
0
5092 item->d_ptr->ignoreVisible = 1;
never executed: item->d_ptr->ignoreVisible = 1;
0
5093 if (ignoreOpacity)
ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5094 item->d_ptr->ignoreOpacity = 1;
never executed: item->d_ptr->ignoreOpacity = 1;
0
5095-
5096 if (!updateBoundingRect)
!updateBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5097 item->d_ptr->markParentDirty();
never executed: item->d_ptr->markParentDirty();
0
5098}
never executed: end of block
0
5099-
5100static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item,-
5101 const QRectF &rect, bool itemIsUntransformable)-
5102{-
5103 Q_ASSERT(view);-
5104 Q_ASSERT(item);-
5105-
5106 QGraphicsItem *itemq = static_cast<QGraphicsItem *>(item->q_ptr);-
5107 QGraphicsView *viewq = static_cast<QGraphicsView *>(view->q_ptr);-
5108-
5109 if (itemIsUntransformable) {
itemIsUntransformableDescription
TRUEnever evaluated
FALSEnever evaluated
0
5110 const QTransform xform = itemq->deviceTransform(viewq->viewportTransform());-
5111 if (!item->hasBoundingRegionGranularity)
!item->hasBoun...ionGranularityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5112 return view->updateRectF(xform.mapRect(rect));
never executed: return view->updateRectF(xform.mapRect(rect));
0
5113 return view->updateRegion(rect, xform);
never executed: return view->updateRegion(rect, xform);
0
5114 }-
5115-
5116 if (item->sceneTransformTranslateOnly && view->identityMatrix) {
item->sceneTra...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
view->identityMatrixDescription
TRUEnever evaluated
FALSEnever evaluated
0
5117 const qreal dx = item->sceneTransform.dx();-
5118 const qreal dy = item->sceneTransform.dy();-
5119 QRectF r(rect);-
5120 r.translate(dx - view->horizontalScroll(), dy - view->verticalScroll());-
5121 return view->updateRectF(r);
never executed: return view->updateRectF(r);
0
5122 }-
5123-
5124 if (!viewq->isTransformed()) {
!viewq->isTransformed()Description
TRUEnever evaluated
FALSEnever evaluated
0
5125 if (!item->hasBoundingRegionGranularity)
!item->hasBoun...ionGranularityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5126 return view->updateRectF(item->sceneTransform.mapRect(rect));
never executed: return view->updateRectF(item->sceneTransform.mapRect(rect));
0
5127 return view->updateRegion(rect, item->sceneTransform);
never executed: return view->updateRegion(rect, item->sceneTransform);
0
5128 }-
5129-
5130 QTransform xform = item->sceneTransform;-
5131 xform *= viewq->viewportTransform();-
5132 if (!item->hasBoundingRegionGranularity)
!item->hasBoun...ionGranularityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5133 return view->updateRectF(xform.mapRect(rect));
never executed: return view->updateRectF(xform.mapRect(rect));
0
5134 return view->updateRegion(rect, xform);
never executed: return view->updateRegion(rect, xform);
0
5135}-
5136-
5137void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren,-
5138 qreal parentOpacity)-
5139{-
5140 Q_Q(QGraphicsScene);-
5141 Q_ASSERT(item);-
5142 Q_ASSERT(!updateAll);-
5143-
5144 if (!item->d_ptr->dirty && !item->d_ptr->dirtyChildren) {
!item->d_ptr->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
!item->d_ptr->dirtyChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5145 resetDirtyItem(item);-
5146 return;
never executed: return;
0
5147 }-
5148-
5149 const bool itemIsHidden = !item->d_ptr->ignoreVisible && !item->d_ptr->visible;
!item->d_ptr->ignoreVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!item->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5150 if (itemIsHidden) {
itemIsHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5151 resetDirtyItem(item, /*recursive=*/true);-
5152 return;
never executed: return;
0
5153 }-
5154-
5155 bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);-
5156 const bool itemHasChildren = !item->d_ptr->children.isEmpty();-
5157 if (!itemHasContents) {
!itemHasContentsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5158 if (!itemHasChildren) {
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5159 resetDirtyItem(item);-
5160 return; // Item has neither contents nor children!(?)
never executed: return;
0
5161 }-
5162 if (item->d_ptr->graphicsEffect)
item->d_ptr->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5163 itemHasContents = true;
never executed: itemHasContents = true;
0
5164 }
never executed: end of block
0
5165-
5166 const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);-
5167 const bool itemIsFullyTransparent = !item->d_ptr->ignoreOpacity
!item->d_ptr->ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5168 && QGraphicsItemPrivate::isOpacityNull(opacity);
QGraphicsItemP...yNull(opacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5169 if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity())) {
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->c...mbineOpacity()Description
TRUEnever evaluated
FALSEnever evaluated
0
5170 resetDirtyItem(item, /*recursive=*/itemHasChildren);-
5171 return;
never executed: return;
0
5172 }-
5173-
5174 bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform;-
5175 const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();-
5176 if (wasDirtyParentSceneTransform && !itemIsUntransformable) {
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
!itemIsUntransformableDescription
TRUEnever evaluated
FALSEnever evaluated
0
5177 item->d_ptr->updateSceneTransformFromParent();-
5178 Q_ASSERT(!item->d_ptr->dirtySceneTransform);-
5179 }
never executed: end of block
0
5180-
5181 const bool wasDirtyParentViewBoundingRects = item->d_ptr->paintedViewBoundingRectsNeedRepaint;-
5182 if (itemIsFullyTransparent || !itemHasContents || dirtyAncestorContainsChildren) {
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!itemHasContentsDescription
TRUEnever evaluated
FALSEnever evaluated
dirtyAncestorContainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5183 // Make sure we don't process invisible items or items with no content.-
5184 item->d_ptr->dirty = 0;-
5185 item->d_ptr->fullUpdatePending = 0;-
5186 // Might have a dirty view bounding rect otherwise.-
5187 if (itemIsFullyTransparent || !itemHasContents)
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!itemHasContentsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5188 item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
never executed: item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
0
5189 }
never executed: end of block
0
5190-
5191 if (!hasSceneRect && item->d_ptr->geometryChanged && item->d_ptr->visible) {
!hasSceneRectDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->geometryChangedDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5192 // Update growingItemsBoundingRect.-
5193 if (item->d_ptr->sceneTransformTranslateOnly) {
item->d_ptr->s...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
5194 growingItemsBoundingRect |= item->boundingRect().translated(item->d_ptr->sceneTransform.dx(),-
5195 item->d_ptr->sceneTransform.dy());-
5196 } else {
never executed: end of block
0
5197 growingItemsBoundingRect |= item->d_ptr->sceneTransform.mapRect(item->boundingRect());-
5198 }
never executed: end of block
0
5199 }-
5200-
5201 // Process item.-
5202 if (item->d_ptr->dirty || item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
item->d_ptr->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->p...ctsNeedRepaintDescription
TRUEnever evaluated
FALSEnever evaluated
0
5203 const bool useCompatUpdate = views.isEmpty() || isSignalConnected(changedSignalIndex);
views.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
isSignalConnec...edSignalIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
5204 const QRectF itemBoundingRect = adjustedItemEffectiveBoundingRect(item);-
5205-
5206 if (useCompatUpdate && !itemIsUntransformable && qFuzzyIsNull(item->boundingRegionGranularity())) {
useCompatUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
!itemIsUntransformableDescription
TRUEnever evaluated
FALSEnever evaluated
qFuzzyIsNull(i...Granularity())Description
TRUEnever evaluated
FALSEnever evaluated
0
5207 // This block of code is kept for compatibility. Since 4.5, by default-
5208 // QGraphicsView does not connect the signal and we use the below-
5209 // method of delivering updates.-
5210 if (item->d_ptr->sceneTransformTranslateOnly) {
item->d_ptr->s...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
5211 q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(),-
5212 item->d_ptr->sceneTransform.dy()));-
5213 } else {
never executed: end of block
0
5214 QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect);-
5215 if (!rect.isEmpty())
!rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5216 q->update(rect);
never executed: q->update(rect);
0
5217 }
never executed: end of block
0
5218 } else {-
5219 QRectF dirtyRect;-
5220 bool uninitializedDirtyRect = true;-
5221-
5222 for (int j = 0; j < views.size(); ++j) {
j < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5223 QGraphicsView *view = views.at(j);-
5224 QGraphicsViewPrivate *viewPrivate = view->d_func();-
5225 QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport];-
5226 if (viewPrivate->fullUpdatePending
viewPrivate->fullUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5227 || viewPrivate->viewportUpdateMode == QGraphicsView::NoViewportUpdate) {
viewPrivate->v...ViewportUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
5228 // Okay, if we have a full update pending or no viewport update, this item's-
5229 // paintedViewBoundingRect will be updated correctly in the next paintEvent if-
5230 // it is inside the viewport, but for now we can pretend that it is outside.-
5231 paintedViewBoundingRect = QRect(-1, -1, -1, -1);-
5232 continue;
never executed: continue;
0
5233 }-
5234-
5235 if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
item->d_ptr->p...ctsNeedRepaintDescription
TRUEnever evaluated
FALSEnever evaluated
0
5236 paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset);-
5237 if (!viewPrivate->updateRect(paintedViewBoundingRect))
!viewPrivate->...wBoundingRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
5238 paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.
never executed: paintedViewBoundingRect = QRect(-1, -1, -1, -1);
0
5239 }
never executed: end of block
0
5240-
5241 if (!item->d_ptr->dirty)
!item->d_ptr->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
5242 continue;
never executed: continue;
0
5243-
5244 if (!item->d_ptr->paintedViewBoundingRectsNeedRepaint
!item->d_ptr->...ctsNeedRepaintDescription
TRUEnever evaluated
FALSEnever evaluated
0
5245 && paintedViewBoundingRect.x() == -1 && paintedViewBoundingRect.y() == -1
paintedViewBou...Rect.x() == -1Description
TRUEnever evaluated
FALSEnever evaluated
paintedViewBou...Rect.y() == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5246 && paintedViewBoundingRect.width() == -1 && paintedViewBoundingRect.height() == -1) {
paintedViewBou....width() == -1Description
TRUEnever evaluated
FALSEnever evaluated
paintedViewBou...height() == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5247 continue; // Outside viewport.
never executed: continue;
0
5248 }-
5249-
5250 if (uninitializedDirtyRect) {
uninitializedDirtyRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5251 dirtyRect = itemBoundingRect;-
5252 if (!item->d_ptr->fullUpdatePending) {
!item->d_ptr->...lUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5253 _q_adjustRect(&item->d_ptr->needsRepaint);-
5254 dirtyRect &= item->d_ptr->needsRepaint;-
5255 }
never executed: end of block
0
5256 uninitializedDirtyRect = false;-
5257 }
never executed: end of block
0
5258-
5259 if (dirtyRect.isEmpty())
dirtyRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5260 continue; // Discard updates outside the bounding rect.
never executed: continue;
0
5261-
5262 if (!updateHelper(viewPrivate, item->d_ptr.data(), dirtyRect, itemIsUntransformable)
!updateHelper(...transformable)Description
TRUEnever evaluated
FALSEnever evaluated
0
5263 && item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
item->d_ptr->p...ctsNeedRepaintDescription
TRUEnever evaluated
FALSEnever evaluated
0
5264 paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.-
5265 }
never executed: end of block
0
5266 }
never executed: end of block
0
5267 }
never executed: end of block
0
5268 }-
5269-
5270 // Process children.-
5271 if (itemHasChildren && item->d_ptr->dirtyChildren) {
itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->dirtyChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5272 const bool itemClipsChildrenToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape
item->d_ptr->f...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5273 || item->d_ptr->flags & QGraphicsItem::ItemContainsChildrenInShape;
item->d_ptr->f...hildrenInShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5274 // Items with no content are threated as 'dummy' items which means they are never drawn and-
5275 // 'processed', so the painted view bounding rect is never up-to-date. This means that whenever-
5276 // such an item changes geometry, its children have to take care of the update regardless-
5277 // of whether the item clips children to shape or not.-
5278 const bool bypassUpdateClip = !itemHasContents && wasDirtyParentViewBoundingRects;
!itemHasContentsDescription
TRUEnever evaluated
FALSEnever evaluated
wasDirtyParent...wBoundingRectsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5279 if (itemClipsChildrenToShape && !bypassUpdateClip) {
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
!bypassUpdateClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
5280 // Make sure child updates are clipped to the item's bounding rect.-
5281 for (int i = 0; i < views.size(); ++i)
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5282 views.at(i)->d_func()->setUpdateClip(item);
never executed: views.at(i)->d_func()->setUpdateClip(item);
0
5283 }
never executed: end of block
0
5284 if (!dirtyAncestorContainsChildren) {
!dirtyAncestorContainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5285 dirtyAncestorContainsChildren = item->d_ptr->fullUpdatePending
item->d_ptr->fullUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5286 && itemClipsChildrenToShape;
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5287 }
never executed: end of block
0
5288 const bool allChildrenDirty = item->d_ptr->allChildrenDirty;-
5289 const bool parentIgnoresVisible = item->d_ptr->ignoreVisible;-
5290 const bool parentIgnoresOpacity = item->d_ptr->ignoreOpacity;-
5291 for (int i = 0; i < item->d_ptr->children.size(); ++i) {
i < item->d_pt...hildren.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5292 QGraphicsItem *child = item->d_ptr->children.at(i);-
5293 if (wasDirtyParentSceneTransform)
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5294 child->d_ptr->dirtySceneTransform = 1;
never executed: child->d_ptr->dirtySceneTransform = 1;
0
5295 if (wasDirtyParentViewBoundingRects)
wasDirtyParent...wBoundingRectsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5296 child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
never executed: child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
0
5297 if (parentIgnoresVisible)
parentIgnoresVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5298 child->d_ptr->ignoreVisible = 1;
never executed: child->d_ptr->ignoreVisible = 1;
0
5299 if (parentIgnoresOpacity)
parentIgnoresOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5300 child->d_ptr->ignoreOpacity = 1;
never executed: child->d_ptr->ignoreOpacity = 1;
0
5301 if (allChildrenDirty) {
allChildrenDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
5302 child->d_ptr->dirty = 1;-
5303 child->d_ptr->fullUpdatePending = 1;-
5304 child->d_ptr->dirtyChildren = 1;-
5305 child->d_ptr->allChildrenDirty = 1;-
5306 }
never executed: end of block
0
5307 processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity);-
5308 }
never executed: end of block
0
5309-
5310 if (itemClipsChildrenToShape) {
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5311 // Reset updateClip.-
5312 for (int i = 0; i < views.size(); ++i)
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5313 views.at(i)->d_func()->setUpdateClip(0);
never executed: views.at(i)->d_func()->setUpdateClip(0);
0
5314 }
never executed: end of block
0
5315 } else if (wasDirtyParentSceneTransform) {
never executed: end of block
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5316 item->d_ptr->invalidateChildrenSceneTransform();-
5317 }
never executed: end of block
0
5318-
5319 resetDirtyItem(item);-
5320}
never executed: end of block
0
5321-
5322/*!-
5323 \obsolete-
5324-
5325 Paints the given \a items using the provided \a painter, after the-
5326 background has been drawn, and before the foreground has been-
5327 drawn. All painting is done in \e scene coordinates. Before-
5328 drawing each item, the painter must be transformed using-
5329 QGraphicsItem::sceneTransform().-
5330-
5331 The \a options parameter is the list of style option objects for-
5332 each item in \a items. The \a numItems parameter is the number of-
5333 items in \a items and options in \a options. The \a widget-
5334 parameter is optional; if specified, it should point to the widget-
5335 that is being painted on.-
5336-
5337 The default implementation prepares the painter matrix, and calls-
5338 QGraphicsItem::paint() on all items. Reimplement this function to-
5339 provide custom painting of all items for the scene; gaining-
5340 complete control over how each item is drawn. In some cases this-
5341 can increase drawing performance significantly.-
5342-
5343 Example:-
5344-
5345 \snippet graphicssceneadditemsnippet.cpp 0-
5346-
5347 Since Qt 4.6, this function is not called anymore unless-
5348 the QGraphicsView::IndirectPainting flag is given as an Optimization-
5349 flag.-
5350-
5351 \sa drawBackground(), drawForeground()-
5352*/-
5353void QGraphicsScene::drawItems(QPainter *painter,-
5354 int numItems,-
5355 QGraphicsItem *items[],-
5356 const QStyleOptionGraphicsItem options[], QWidget *widget)-
5357{-
5358 Q_D(QGraphicsScene);-
5359 // Make sure we don't have unpolished items before we draw.-
5360 if (!d->unpolishedItems.isEmpty())
!d->unpolishedItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5361 d->_q_polishItems();
never executed: d->_q_polishItems();
0
5362-
5363 const qreal opacity = painter->opacity();-
5364 QTransform viewTransform = painter->worldTransform();-
5365 Q_UNUSED(options);-
5366-
5367 // Determine view, expose and flags.-
5368 QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
5369 QRegion *expose = 0;-
5370 const quint32 oldRectAdjust = d->rectAdjust;-
5371 if (view) {
viewDescription
TRUEnever evaluated
FALSEnever evaluated
0
5372 d->updateAll = false;-
5373 expose = &view->d_func()->exposedRegion;-
5374 if (view->d_func()->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
view->d_func()...orAntialiasingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5375 d->rectAdjust = 1;
never executed: d->rectAdjust = 1;
0
5376 else-
5377 d->rectAdjust = 2;
never executed: d->rectAdjust = 2;
0
5378 }-
5379-
5380 // Find all toplevels, they are already sorted.-
5381 QList<QGraphicsItem *> topLevelItems;-
5382 for (int i = 0; i < numItems; ++i) {
i < numItemsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5383 QGraphicsItem *item = items[i]->topLevelItem();-
5384 if (!item->d_ptr->itemDiscovered) {
!item->d_ptr->itemDiscoveredDescription
TRUEnever evaluated
FALSEnever evaluated
0
5385 topLevelItems << item;-
5386 item->d_ptr->itemDiscovered = 1;-
5387 d->drawSubtreeRecursive(item, painter, &viewTransform, expose, widget);-
5388 }
never executed: end of block
0
5389 }
never executed: end of block
0
5390-
5391 d->rectAdjust = oldRectAdjust;-
5392 // Reset discovery bits.-
5393 for (int i = 0; i < topLevelItems.size(); ++i)
i < topLevelItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5394 topLevelItems.at(i)->d_ptr->itemDiscovered = 0;
never executed: topLevelItems.at(i)->d_ptr->itemDiscovered = 0;
0
5395-
5396 painter->setWorldTransform(viewTransform);-
5397 painter->setOpacity(opacity);-
5398}
never executed: end of block
0
5399-
5400/*!-
5401 \since 4.4-
5402-
5403 Finds a new widget to give the keyboard focus to, as appropriate for Tab-
5404 and Shift+Tab, and returns \c true if it can find a new widget, or false if-
5405 it cannot. If \a next is true, this function searches forward; if \a next-
5406 is false, it searches backward.-
5407-
5408 You can reimplement this function in a subclass of QGraphicsScene to-
5409 provide fine-grained control over how tab focus passes inside your-
5410 scene. The default implementation is based on the tab focus chain defined-
5411 by QGraphicsWidget::setTabOrder().-
5412*/-
5413bool QGraphicsScene::focusNextPrevChild(bool next)-
5414{-
5415 Q_D(QGraphicsScene);-
5416-
5417 QGraphicsItem *item = focusItem();-
5418 if (item && !item->isWidget()) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
!item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
5419 // Tab out of the scene.-
5420 return false;
never executed: return false;
0
5421 }-
5422 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5423 if (d->lastFocusItem && !d->lastFocusItem->isWidget()) {
d->lastFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
!d->lastFocusItem->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
5424 // Restore focus to the last focusable non-widget item that had-
5425 // focus.-
5426 setFocusItem(d->lastFocusItem, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);-
5427 return true;
never executed: return true;
0
5428 }-
5429 if (d->activePanel) {
d->activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
5430 if (d->activePanel->flags() & QGraphicsItem::ItemIsFocusable) {
d->activePanel...temIsFocusableDescription
TRUEnever evaluated
FALSEnever evaluated
0
5431 setFocusItem(d->activePanel, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);-
5432 return true;
never executed: return true;
0
5433 }-
5434 if (d->activePanel->isWidget()) {
d->activePanel->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
5435 QGraphicsWidget *fw = static_cast<QGraphicsWidget *>(d->activePanel)->d_func()->focusNext;-
5436 do {-
5437 if (fw->focusPolicy() & Qt::TabFocus) {
fw->focusPolic...& Qt::TabFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
5438 setFocusItem(fw, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);-
5439 return true;
never executed: return true;
0
5440 }-
5441 } while (fw != d->activePanel);
never executed: end of block
fw != d->activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
5442 }
never executed: end of block
0
5443 }
never executed: end of block
0
5444 }
never executed: end of block
0
5445 if (!item && !d->tabFocusFirst) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
!d->tabFocusFirstDescription
TRUEnever evaluated
FALSEnever evaluated
0
5446 // No widgets...-
5447 return false;
never executed: return false;
0
5448 }-
5449-
5450 // The item must be a widget.-
5451 QGraphicsWidget *widget = 0;-
5452 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5453 widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev;
nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
5454 } else {
never executed: end of block
0
5455 QGraphicsWidget *test = static_cast<QGraphicsWidget *>(item);-
5456 widget = next ? test->d_func()->focusNext : test->d_func()->focusPrev;
nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
5457 if (!widget->panel() && ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))) {
!widget->panel()Description
TRUEnever evaluated
FALSEnever evaluated
nextDescription
TRUEnever evaluated
FALSEnever evaluated
widget == d->tabFocusFirstDescription
TRUEnever evaluated
FALSEnever evaluated
!nextDescription
TRUEnever evaluated
FALSEnever evaluated
widget == d->t...c()->focusPrevDescription
TRUEnever evaluated
FALSEnever evaluated
0
5458 // Tab out of the scene.-
5459 return false;
never executed: return false;
0
5460 }-
5461 }
never executed: end of block
0
5462 QGraphicsWidget *widgetThatHadFocus = widget;-
5463-
5464 // Run around the focus chain until we find a widget that can take tab focus.-
5465 do {-
5466 if (widget->flags() & QGraphicsItem::ItemIsFocusable
widget->flags(...temIsFocusableDescription
TRUEnever evaluated
FALSEnever evaluated
0
5467 && widget->isEnabled() && widget->isVisibleTo(0)
widget->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
widget->isVisibleTo(0)Description
TRUEnever evaluated
FALSEnever evaluated
0
5468 && (widget->focusPolicy() & Qt::TabFocus)
(widget->focus... Qt::TabFocus)Description
TRUEnever evaluated
FALSEnever evaluated
0
5469 && (!item || !item->isPanel() || item->isAncestorOf(widget))
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
!item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
item->isAncestorOf(widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
5470 ) {-
5471 setFocusItem(widget, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);-
5472 return true;
never executed: return true;
0
5473 }-
5474 widget = next ? widget->d_func()->focusNext : widget->d_func()->focusPrev;
nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
5475 if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))
nextDescription
TRUEnever evaluated
FALSEnever evaluated
widget == d->tabFocusFirstDescription
TRUEnever evaluated
FALSEnever evaluated
!nextDescription
TRUEnever evaluated
FALSEnever evaluated
widget == d->t...c()->focusPrevDescription
TRUEnever evaluated
FALSEnever evaluated
0
5476 return false;
never executed: return false;
0
5477 } while (widget != widgetThatHadFocus);
never executed: end of block
widget != widgetThatHadFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
5478-
5479 return false;
never executed: return false;
0
5480}-
5481-
5482/*!-
5483 \fn QGraphicsScene::changed(const QList<QRectF> &region)-
5484-
5485 This signal is emitted by QGraphicsScene when control reaches the-
5486 event loop, if the scene content changes. The \a region parameter-
5487 contains a list of scene rectangles that indicate the area that-
5488 has been changed.-
5489-
5490 \sa QGraphicsView::updateScene()-
5491*/-
5492-
5493/*!-
5494 \fn QGraphicsScene::sceneRectChanged(const QRectF &rect)-
5495-
5496 This signal is emitted by QGraphicsScene whenever the scene rect changes.-
5497 The \a rect parameter is the new scene rectangle.-
5498-
5499 \sa QGraphicsView::updateSceneRect()-
5500*/-
5501-
5502/*!-
5503 \fn QGraphicsScene::selectionChanged()-
5504 \since 4.3-
5505-
5506 This signal is emitted by QGraphicsScene whenever the selection-
5507 changes. You can call selectedItems() to get the new list of selected-
5508 items.-
5509-
5510 The selection changes whenever an item is selected or unselected, a-
5511 selection area is set, cleared or otherwise changed, if a preselected item-
5512 is added to the scene, or if a selected item is removed from the scene.-
5513-
5514 QGraphicsScene emits this signal only once for group selection operations.-
5515 For example, if you set a selection area, select or unselect a-
5516 QGraphicsItemGroup, or if you add or remove from the scene a parent item-
5517 that contains several selected items, selectionChanged() is emitted only-
5518 once after the operation has completed (instead of once for each item).-
5519-
5520 \sa setSelectionArea(), selectedItems(), QGraphicsItem::setSelected()-
5521*/-
5522-
5523/*!-
5524 \fn QGraphicsScene::focusItemChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason)-
5525-
5526 This signal is emitted by QGraphicsScene whenever focus changes in the-
5527 scene (i.e., when an item gains or loses input focus, or when focus-
5528 passes from one item to another). You can connect to this signal if you-
5529 need to keep track of when other items gain input focus. It is-
5530 particularly useful for implementing virtual keyboards, input methods,-
5531 and cursor items.-
5532-
5533 \a oldFocusItem is a pointer to the item that previously had focus, or-
5534 0 if no item had focus before the signal was emitted. \a newFocusItem-
5535 is a pointer to the item that gained input focus, or 0 if focus was lost.-
5536 \a reason is the reason for the focus change (e.g., if the scene was-
5537 deactivated while an input field had focus, \a oldFocusItem would point-
5538 to the input field item, \a newFocusItem would be 0, and \a reason would be-
5539 Qt::ActiveWindowFocusReason.-
5540*/-
5541-
5542/*!-
5543 \since 4.4-
5544-
5545 Returns the scene's style, or the same as QApplication::style() if the-
5546 scene has not been explicitly assigned a style.-
5547-
5548 \sa setStyle()-
5549*/-
5550QStyle *QGraphicsScene::style() const-
5551{-
5552 Q_D(const QGraphicsScene);-
5553 // ### This function, and the use of styles in general, is non-reentrant.-
5554 return d->style ? d->style : QApplication::style();
never executed: return d->style ? d->style : QApplication::style();
0
5555}-
5556-
5557/*!-
5558 \since 4.4-
5559-
5560 Sets or replaces the style of the scene to \a style, and reparents the-
5561 style to this scene. Any previously assigned style is deleted. The scene's-
5562 style defaults to QApplication::style(), and serves as the default for all-
5563 QGraphicsWidget items in the scene.-
5564-
5565 Changing the style, either directly by calling this function, or-
5566 indirectly by calling QApplication::setStyle(), will automatically update-
5567 the style for all widgets in the scene that do not have a style explicitly-
5568 assigned to them.-
5569-
5570 If \a style is 0, QGraphicsScene will revert to QApplication::style().-
5571-
5572 \sa style()-
5573*/-
5574void QGraphicsScene::setStyle(QStyle *style)-
5575{-
5576 Q_D(QGraphicsScene);-
5577 // ### This function, and the use of styles in general, is non-reentrant.-
5578 if (style == d->style)
style == d->styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5579 return;
never executed: return;
0
5580-
5581 // Delete the old style,-
5582 delete d->style;-
5583 if ((d->style = style))
(d->style = style)Description
TRUEnever evaluated
FALSEnever evaluated
0
5584 d->style->setParent(this);
never executed: d->style->setParent(this);
0
5585-
5586 // Notify the scene.-
5587 QEvent event(QEvent::StyleChange);-
5588 QApplication::sendEvent(this, &event);-
5589-
5590 // Notify all widgets that don't have a style explicitly set.-
5591 const auto items_ = items();-
5592 for (QGraphicsItem *item : items_) {-
5593 if (item->isWidget()) {
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
5594 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);-
5595 if (!widget->testAttribute(Qt::WA_SetStyle))
!widget->testA...::WA_SetStyle)Description
TRUEnever evaluated
FALSEnever evaluated
0
5596 QApplication::sendEvent(widget, &event);
never executed: QApplication::sendEvent(widget, &event);
0
5597 }
never executed: end of block
0
5598 }
never executed: end of block
0
5599}
never executed: end of block
0
5600-
5601/*!-
5602 \property QGraphicsScene::font-
5603 \since 4.4-
5604 \brief the scene's default font-
5605-
5606 This property provides the scene's font. The scene font defaults to,-
5607 and resolves all its entries from, QApplication::font.-
5608-
5609 If the scene's font changes, either directly through setFont() or-
5610 indirectly when the application font changes, QGraphicsScene first-
5611 sends itself a \l{QEvent::FontChange}{FontChange} event, and it then-
5612 sends \l{QEvent::FontChange}{FontChange} events to all top-level-
5613 widget items in the scene. These items respond by resolving their own-
5614 fonts to the scene, and they then notify their children, who again-
5615 notify their children, and so on, until all widget items have updated-
5616 their fonts.-
5617-
5618 Changing the scene font, (directly or indirectly through-
5619 QApplication::setFont(),) automatically schedules a redraw the entire-
5620 scene.-
5621-
5622 \sa QWidget::font, QApplication::setFont(), palette, style()-
5623*/-
5624QFont QGraphicsScene::font() const-
5625{-
5626 Q_D(const QGraphicsScene);-
5627 return d->font;
never executed: return d->font;
0
5628}-
5629void QGraphicsScene::setFont(const QFont &font)-
5630{-
5631 Q_D(QGraphicsScene);-
5632 QFont naturalFont = QApplication::font();-
5633 naturalFont.resolve(0);-
5634 QFont resolvedFont = font.resolve(naturalFont);-
5635 d->setFont_helper(resolvedFont);-
5636}
never executed: end of block
0
5637-
5638/*!-
5639 \property QGraphicsScene::palette-
5640 \since 4.4-
5641 \brief the scene's default palette-
5642-
5643 This property provides the scene's palette. The scene palette defaults to,-
5644 and resolves all its entries from, QApplication::palette.-
5645-
5646 If the scene's palette changes, either directly through setPalette() or-
5647 indirectly when the application palette changes, QGraphicsScene first-
5648 sends itself a \l{QEvent::PaletteChange}{PaletteChange} event, and it then-
5649 sends \l{QEvent::PaletteChange}{PaletteChange} events to all top-level-
5650 widget items in the scene. These items respond by resolving their own-
5651 palettes to the scene, and they then notify their children, who again-
5652 notify their children, and so on, until all widget items have updated-
5653 their palettes.-
5654-
5655 Changing the scene palette, (directly or indirectly through-
5656 QApplication::setPalette(),) automatically schedules a redraw the entire-
5657 scene.-
5658-
5659 \sa QWidget::palette, QApplication::setPalette(), font, style()-
5660*/-
5661QPalette QGraphicsScene::palette() const-
5662{-
5663 Q_D(const QGraphicsScene);-
5664 return d->palette;
never executed: return d->palette;
0
5665}-
5666void QGraphicsScene::setPalette(const QPalette &palette)-
5667{-
5668 Q_D(QGraphicsScene);-
5669 QPalette naturalPalette = QApplication::palette();-
5670 naturalPalette.resolve(0);-
5671 QPalette resolvedPalette = palette.resolve(naturalPalette);-
5672 d->setPalette_helper(resolvedPalette);-
5673}
never executed: end of block
0
5674-
5675/*!-
5676 \since 4.6-
5677-
5678 Returns \c true if the scene is active (e.g., it's viewed by-
5679 at least one QGraphicsView that is active); otherwise returns \c false.-
5680-
5681 \sa QGraphicsItem::isActive(), QWidget::isActiveWindow()-
5682*/-
5683bool QGraphicsScene::isActive() const-
5684{-
5685 Q_D(const QGraphicsScene);-
5686 return d->activationRefCount > 0;
never executed: return d->activationRefCount > 0;
0
5687}-
5688-
5689/*!-
5690 \since 4.6-
5691 Returns the current active panel, or 0 if no panel is currently active.-
5692-
5693 \sa QGraphicsScene::setActivePanel()-
5694*/-
5695QGraphicsItem *QGraphicsScene::activePanel() const-
5696{-
5697 Q_D(const QGraphicsScene);-
5698 return d->activePanel;
never executed: return d->activePanel;
0
5699}-
5700-
5701/*!-
5702 \since 4.6-
5703 Activates \a item, which must be an item in this scene. You-
5704 can also pass 0 for \a item, in which case QGraphicsScene will-
5705 deactivate any currently active panel.-
5706-
5707 If the scene is currently inactive, \a item remains inactive until the-
5708 scene becomes active (or, ir \a item is 0, no item will be activated).-
5709-
5710 \sa activePanel(), isActive(), QGraphicsItem::isActive()-
5711*/-
5712void QGraphicsScene::setActivePanel(QGraphicsItem *item)-
5713{-
5714 Q_D(QGraphicsScene);-
5715 d->setActivePanelHelper(item, false);-
5716}
never executed: end of block
0
5717-
5718/*!-
5719 \since 4.4-
5720-
5721 Returns the current active window, or 0 if no window is currently-
5722 active.-
5723-
5724 \sa QGraphicsScene::setActiveWindow()-
5725*/-
5726QGraphicsWidget *QGraphicsScene::activeWindow() const-
5727{-
5728 Q_D(const QGraphicsScene);-
5729 if (d->activePanel && d->activePanel->isWindow())
d->activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
d->activePanel->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
5730 return static_cast<QGraphicsWidget *>(d->activePanel);
never executed: return static_cast<QGraphicsWidget *>(d->activePanel);
0
5731 return 0;
never executed: return 0;
0
5732}-
5733-
5734/*!-
5735 \since 4.4-
5736 Activates \a widget, which must be a widget in this scene. You can also-
5737 pass 0 for \a widget, in which case QGraphicsScene will deactivate any-
5738 currently active window.-
5739-
5740 \sa activeWindow(), QGraphicsWidget::isActiveWindow()-
5741*/-
5742void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget)-
5743{-
5744 if (widget && widget->scene() != this) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
widget->scene() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
5745 qWarning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene",-
5746 widget);-
5747 return;
never executed: return;
0
5748 }-
5749-
5750 // Activate the widget's panel (all windows are panels).-
5751 QGraphicsItem *panel = widget ? widget->panel() : 0;
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
5752 setActivePanel(panel);-
5753-
5754 // Raise-
5755 if (panel) {
panelDescription
TRUEnever evaluated
FALSEnever evaluated
0
5756 QGraphicsItem *parent = panel->parentItem();-
5757 // Raise ### inefficient for toplevels-
5758-
5759 // Find the highest z value.-
5760 qreal z = panel->zValue();-
5761 const auto siblings = parent ? parent->childItems() : items();
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
5762 for (QGraphicsItem *sibling : siblings) {-
5763 if (sibling != panel && sibling->isWindow())
sibling != panelDescription
TRUEnever evaluated
FALSEnever evaluated
sibling->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
5764 z = qMax(z, sibling->zValue());
never executed: z = qMax(z, sibling->zValue());
0
5765 }
never executed: end of block
0
5766-
5767 // This will probably never overflow.-
5768 const qreal litt = qreal(0.001);-
5769 panel->setZValue(z + litt);-
5770 }
never executed: end of block
0
5771}
never executed: end of block
0
5772-
5773/*!-
5774 \since 4.6-
5775-
5776 Sends event \a event to item \a item through possible event filters.-
5777-
5778 The event is sent only if the item is enabled.-
5779-
5780 Returns \c false if the event was filtered or if the item is disabled.-
5781 Otherwise returns the value that was returned from the event handler.-
5782-
5783 \sa QGraphicsItem::sceneEvent(), QGraphicsItem::sceneEventFilter()-
5784*/-
5785bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event)-
5786{-
5787 Q_D(QGraphicsScene);-
5788 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5789 qWarning("QGraphicsScene::sendEvent: cannot send event to a null item");-
5790 return false;
never executed: return false;
0
5791 }-
5792 if (item->scene() != this) {
item->scene() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
5793 qWarning("QGraphicsScene::sendEvent: item %p's scene (%p)"-
5794 " is different from this scene (%p)",-
5795 item, item->scene(), this);-
5796 return false;
never executed: return false;
0
5797 }-
5798 return d->sendEvent(item, event);
never executed: return d->sendEvent(item, event);
0
5799}-
5800-
5801/*!-
5802 \property QGraphicsScene::minimumRenderSize-
5803 \since 5.4-
5804 \brief the minimal view-transformed size an item must have to be drawn-
5805-
5806 When the scene is rendered, any item whose width or height, transformed-
5807 to the target view, is smaller that minimumRenderSize(), will not be-
5808 rendered. If an item is not rendered and it clips its children items-
5809 they will also not be rendered. Set this value to speed up rendering-
5810 of scenes with many objects rendered on a zoomed out view.-
5811-
5812 The default value is 0. If unset, or if set to 0 or a negative value,-
5813 all items will always be rendered.-
5814-
5815 For example, setting this property can be especially useful if a scene-
5816 is rendered by multiple views, one of which serves as an overview which-
5817 always displays all items. In scenes with many items, such a view will-
5818 use a high scaling factor so that all items can be shown. Due to the-
5819 scaling, smaller items will only make an insignificant contribution to-
5820 the final rendered scene. To avoid drawing these items and reduce the-
5821 time necessary to render the scene, you can call setMinimumRenderSize()-
5822 with a non-negative value.-
5823-
5824 \note Items that are not drawn as a result of being too small, are still-
5825 returned by methods such as items() and itemAt(), and participate in-
5826 collision detection and interactions. It is recommended that you set-
5827 minimumRenderSize() to a value less than or equal to 1 in order to-
5828 avoid large unrendered items that are interactive.-
5829-
5830 \sa QStyleOptionGraphicsItem::levelOfDetailFromTransform()-
5831*/-
5832qreal QGraphicsScene::minimumRenderSize() const-
5833{-
5834 Q_D(const QGraphicsScene);-
5835 return d->minimumRenderSize;
never executed: return d->minimumRenderSize;
0
5836}-
5837void QGraphicsScene::setMinimumRenderSize(qreal minSize)-
5838{-
5839 Q_D(QGraphicsScene);-
5840 d->minimumRenderSize = minSize;-
5841 update();-
5842}
never executed: end of block
0
5843-
5844void QGraphicsScenePrivate::addView(QGraphicsView *view)-
5845{-
5846 views << view;-
5847#ifndef QT_NO_GESTURES-
5848 const auto gestures = grabbedGestures.keys();-
5849 for (Qt::GestureType gesture : gestures)-
5850 view->viewport()->grabGesture(gesture);
never executed: view->viewport()->grabGesture(gesture);
0
5851#endif-
5852}
never executed: end of block
0
5853-
5854void QGraphicsScenePrivate::removeView(QGraphicsView *view)-
5855{-
5856 views.removeAll(view);-
5857}
never executed: end of block
0
5858-
5859void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent)-
5860{-
5861 for (auto &touchPoint : touchEvent->_touchPoints) {-
5862 touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect());-
5863 touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), static_cast<QWidget *>(touchEvent->target())));-
5864 touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), static_cast<QWidget *>(touchEvent->target())));-
5865 }
never executed: end of block
0
5866}
never executed: end of block
0
5867-
5868int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos)-
5869{-
5870 int closestTouchPointId = -1;-
5871 qreal closestDistance = qreal(0.);-
5872 foreach (const QTouchEvent::TouchPoint &touchPoint, sceneCurrentTouchPoints) {-
5873 qreal distance = QLineF(scenePos, touchPoint.scenePos()).length();-
5874 if (closestTouchPointId == -1|| distance < closestDistance) {
closestTouchPointId == -1Description
TRUEnever evaluated
FALSEnever evaluated
distance < closestDistanceDescription
TRUEnever evaluated
FALSEnever evaluated
0
5875 closestTouchPointId = touchPoint.id();-
5876 closestDistance = distance;-
5877 }
never executed: end of block
0
5878 }
never executed: end of block
0
5879 return closestTouchPointId;
never executed: return closestTouchPointId;
0
5880}-
5881-
5882void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)-
5883{-
5884 typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;-
5885 QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;-
5886-
5887 for (int i = 0; i < sceneTouchEvent->touchPoints().count(); ++i) {
i < sceneTouch...ints().count()Description
TRUEnever evaluated
FALSEnever evaluated
0
5888 const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i);-
5889-
5890 // update state-
5891 QGraphicsItem *item = 0;-
5892 if (touchPoint.state() == Qt::TouchPointPressed) {
touchPoint.sta...chPointPressedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5893 if (sceneTouchEvent->device()->type() == QTouchDevice::TouchPad) {
sceneTouchEven...vice::TouchPadDescription
TRUEnever evaluated
FALSEnever evaluated
0
5894 // on touch-pad devices, send all touch points to the same item-
5895 item = itemForTouchPointId.isEmpty()
itemForTouchPointId.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5896 ? 0-
5897 : itemForTouchPointId.constBegin().value();-
5898 }
never executed: end of block
0
5899-
5900 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5901 // determine which item this touch point will go to-
5902 cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(),-
5903 touchPoint.scenePos(),-
5904 static_cast<QWidget *>(sceneTouchEvent->target()));-
5905 item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.constFirst();
cachedItemsUnd...ouse.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5906 }
never executed: end of block
0
5907-
5908 if (sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen) {
sceneTouchEven...e::TouchScreenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5909 // on touch-screens, combine this touch point with the closest one we find-
5910 int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos());-
5911 QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId);-
5912 if (!item || (closestItem && cachedItemsUnderMouse.contains(closestItem)))
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
closestItemDescription
TRUEnever evaluated
FALSEnever evaluated
cachedItemsUnd...s(closestItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
5913 item = closestItem;
never executed: item = closestItem;
0
5914 }
never executed: end of block
0
5915 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5916 continue;
never executed: continue;
0
5917-
5918 itemForTouchPointId.insert(touchPoint.id(), item);-
5919 sceneCurrentTouchPoints.insert(touchPoint.id(), touchPoint);-
5920 } else if (touchPoint.state() == Qt::TouchPointReleased) {
never executed: end of block
touchPoint.sta...hPointReleasedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5921 item = itemForTouchPointId.take(touchPoint.id());-
5922 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5923 continue;
never executed: continue;
0
5924-
5925 sceneCurrentTouchPoints.remove(touchPoint.id());-
5926 } else {
never executed: end of block
0
5927 item = itemForTouchPointId.value(touchPoint.id());-
5928 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5929 continue;
never executed: continue;
0
5930 Q_ASSERT(sceneCurrentTouchPoints.contains(touchPoint.id()));-
5931 sceneCurrentTouchPoints[touchPoint.id()] = touchPoint;-
5932 }
never executed: end of block
0
5933-
5934 StatesAndTouchPoints &statesAndTouchPoints = itemsNeedingEvents[item];-
5935 statesAndTouchPoints.first |= touchPoint.state();-
5936 statesAndTouchPoints.second.append(touchPoint);-
5937 }
never executed: end of block
0
5938-
5939 if (itemsNeedingEvents.isEmpty()) {
itemsNeedingEvents.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5940 sceneTouchEvent->ignore();-
5941 return;
never executed: return;
0
5942 }-
5943-
5944 bool ignoreSceneTouchEvent = true;-
5945 QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin();-
5946 const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd();-
5947 for (; it != end; ++it) {
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
5948 QGraphicsItem *item = it.key();-
5949-
5950 (void) item->isBlockedByModalPanel(&item);-
5951-
5952 // determine event type from the state mask-
5953 QEvent::Type eventType;-
5954 switch (it.value().first) {-
5955 case Qt::TouchPointPressed:
never executed: case Qt::TouchPointPressed:
0
5956 // all touch points have pressed state-
5957 eventType = QEvent::TouchBegin;-
5958 break;
never executed: break;
0
5959 case Qt::TouchPointReleased:
never executed: case Qt::TouchPointReleased:
0
5960 // all touch points have released state-
5961 eventType = QEvent::TouchEnd;-
5962 break;
never executed: break;
0
5963 case Qt::TouchPointStationary:
never executed: case Qt::TouchPointStationary:
0
5964 // don't send the event if nothing changed-
5965 continue;
never executed: continue;
0
5966 default:
never executed: default:
0
5967 // all other combinations-
5968 eventType = QEvent::TouchUpdate;-
5969 break;
never executed: break;
0
5970 }-
5971-
5972 QTouchEvent touchEvent(eventType);-
5973 touchEvent.setWindow(sceneTouchEvent->window());-
5974 touchEvent.setTarget(sceneTouchEvent->target());-
5975 touchEvent.setDevice(sceneTouchEvent->device());-
5976 touchEvent.setModifiers(sceneTouchEvent->modifiers());-
5977 touchEvent.setTouchPointStates(it.value().first);-
5978 touchEvent.setTouchPoints(it.value().second);-
5979 touchEvent.setTimestamp(sceneTouchEvent->timestamp());-
5980-
5981 switch (touchEvent.type()) {-
5982 case QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
5983 {-
5984 // if the TouchBegin handler recurses, we assume that means the event-
5985 // has been implicitly accepted and continue to send touch events-
5986 item->d_ptr->acceptedTouchBeginEvent = true;-
5987 bool res = sendTouchBeginEvent(item, &touchEvent)
sendTouchBegin..., &touchEvent)Description
TRUEnever evaluated
FALSEnever evaluated
0
5988 && touchEvent.isAccepted();
touchEvent.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
5989 if (!res) {
!resDescription
TRUEnever evaluated
FALSEnever evaluated
0
5990 // forget about these touch points, we didn't handle them-
5991 for (int i = 0; i < touchEvent.touchPoints().count(); ++i) {
i < touchEvent...ints().count()Description
TRUEnever evaluated
FALSEnever evaluated
0
5992 const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i);-
5993 itemForTouchPointId.remove(touchPoint.id());-
5994 sceneCurrentTouchPoints.remove(touchPoint.id());-
5995 }
never executed: end of block
0
5996 ignoreSceneTouchEvent = false;-
5997 }
never executed: end of block
0
5998 break;
never executed: break;
0
5999 }-
6000 default:
never executed: default:
0
6001 if (item->d_ptr->acceptedTouchBeginEvent) {
item->d_ptr->a...ouchBeginEventDescription
TRUEnever evaluated
FALSEnever evaluated
0
6002 updateTouchPointsForItem(item, &touchEvent);-
6003 (void) sendEvent(item, &touchEvent);-
6004 ignoreSceneTouchEvent = false;-
6005 }
never executed: end of block
0
6006 break;
never executed: break;
0
6007 }-
6008 }-
6009 sceneTouchEvent->setAccepted(ignoreSceneTouchEvent);-
6010}
never executed: end of block
0
6011-
6012bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEvent *touchEvent)-
6013{-
6014 Q_Q(QGraphicsScene);-
6015-
6016 if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) {
cachedItemsUnd...ouse.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
cachedItemsUnd...st() != originDescription
TRUEnever evaluated
FALSEnever evaluated
0
6017 const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first();-
6018 cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(),-
6019 firstTouchPoint.scenePos(),-
6020 static_cast<QWidget *>(touchEvent->target()));-
6021 }
never executed: end of block
0
6022-
6023 // Set focus on the topmost enabled item that can take focus.-
6024 bool setFocus = false;-
6025-
6026 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {-
6027 if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
item->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
(item->flags()...emIsFocusable)Description
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->mouseSetsFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
6028 if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
!item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
((QGraphicsWid...Qt::ClickFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
6029 setFocus = true;-
6030 if (item != q->focusItem())
item != q->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
6031 q->setFocusItem(item, Qt::MouseFocusReason);
never executed: q->setFocusItem(item, Qt::MouseFocusReason);
0
6032 break;
never executed: break;
0
6033 }-
6034 }
never executed: end of block
0
6035 if (item->isPanel())
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6036 break;
never executed: break;
0
6037 if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
item->d_ptr->f...cusPropagationDescription
TRUEnever evaluated
FALSEnever evaluated
0
6038 break;
never executed: break;
0
6039 if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) {
item->d_ptr->f...sFocusHandlingDescription
TRUEnever evaluated
FALSEnever evaluated
0
6040 // Make sure we don't clear focus.-
6041 setFocus = true;-
6042 break;
never executed: break;
0
6043 }-
6044 }
never executed: end of block
0
6045-
6046 // If nobody could take focus, clear it.-
6047 if (!stickyFocus && !setFocus)
!stickyFocusDescription
TRUEnever evaluated
FALSEnever evaluated
!setFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
6048 q->setFocusItem(0, Qt::MouseFocusReason);
never executed: q->setFocusItem(0, Qt::MouseFocusReason);
0
6049-
6050 bool res = false;-
6051 bool eventAccepted = touchEvent->isAccepted();-
6052 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {-
6053 // first, try to deliver the touch event-
6054 updateTouchPointsForItem(item, touchEvent);-
6055 bool acceptTouchEvents = item->acceptTouchEvents();-
6056 touchEvent->setAccepted(acceptTouchEvents);-
6057 res = acceptTouchEvents && sendEvent(item, touchEvent);
acceptTouchEventsDescription
TRUEnever evaluated
FALSEnever evaluated
sendEvent(item, touchEvent)Description
TRUEnever evaluated
FALSEnever evaluated
0
6058 eventAccepted = touchEvent->isAccepted();-
6059 if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
itemForTouchPo...t().id()) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6060 // item was deleted-
6061 item = 0;-
6062 } else {
never executed: end of block
0
6063 item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
resDescription
TRUEnever evaluated
FALSEnever evaluated
eventAcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6064 }
never executed: end of block
0
6065 touchEvent->spont = false;-
6066 if (res && eventAccepted) {
resDescription
TRUEnever evaluated
FALSEnever evaluated
eventAcceptedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6067 // the first item to accept the TouchBegin gets an implicit grab.-
6068 for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
i < touchEvent...ints().count()Description
TRUEnever evaluated
FALSEnever evaluated
0
6069 const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);-
6070 itemForTouchPointId[touchPoint.id()] = item; // can be zero-
6071 }
never executed: end of block
0
6072 break;
never executed: break;
0
6073 }-
6074 if (item && item->isPanel())
itemDescription
TRUEnever evaluated
FALSEnever evaluated
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6075 break;
never executed: break;
0
6076 }
never executed: end of block
0
6077-
6078 touchEvent->setAccepted(eventAccepted);-
6079 return res;
never executed: return res;
0
6080}-
6081-
6082void QGraphicsScenePrivate::enableTouchEventsOnViews()-
6083{-
6084 foreach (QGraphicsView *view, views)-
6085 view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
never executed: view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
0
6086}
never executed: end of block
0
6087-
6088void QGraphicsScenePrivate::updateInputMethodSensitivityInViews()-
6089{-
6090 for (int i = 0; i < views.size(); ++i)
i < views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
6091 views.at(i)->d_func()->updateInputMethodSensitivity();
never executed: views.at(i)->d_func()->updateInputMethodSensitivity();
0
6092}
never executed: end of block
0
6093-
6094void QGraphicsScenePrivate::enterModal(QGraphicsItem *panel, QGraphicsItem::PanelModality previousModality)-
6095{-
6096 Q_Q(QGraphicsScene);-
6097 Q_ASSERT(panel && panel->isPanel());-
6098-
6099 QGraphicsItem::PanelModality panelModality = panel->d_ptr->panelModality;-
6100 if (previousModality != QGraphicsItem::NonModal) {
previousModali...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
6101 // the panel is changing from one modality type to another... temporarily set it back so-
6102 // that blockedPanels is populated correctly-
6103 panel->d_ptr->panelModality = previousModality;-
6104 }
never executed: end of block
0
6105-
6106 QSet<QGraphicsItem *> blockedPanels;-
6107 QList<QGraphicsItem *> items = q->items(); // ### store panels separately-
6108 for (int i = 0; i < items.count(); ++i) {
i < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
6109 QGraphicsItem *item = items.at(i);-
6110 if (item->isPanel() && item->isBlockedByModalPanel())
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6111 blockedPanels.insert(item);
never executed: blockedPanels.insert(item);
0
6112 }
never executed: end of block
0
6113 // blockedPanels contains all currently blocked panels-
6114-
6115 if (previousModality != QGraphicsItem::NonModal) {
previousModali...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
6116 // reset the modality to the proper value, since we changed it above-
6117 panel->d_ptr->panelModality = panelModality;-
6118 // remove this panel so that it will be reinserted at the front of the stack-
6119 modalPanels.removeAll(panel);-
6120 }
never executed: end of block
0
6121-
6122 modalPanels.prepend(panel);-
6123-
6124 if (!hoverItems.isEmpty()) {
!hoverItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6125 // send GraphicsSceneHoverLeave events to newly blocked hoverItems-
6126 QGraphicsSceneHoverEvent hoverEvent;-
6127 hoverEvent.setScenePos(lastSceneMousePos);-
6128 dispatchHoverEvent(&hoverEvent);-
6129 }
never executed: end of block
0
6130-
6131 if (!mouseGrabberItems.isEmpty() && lastMouseGrabberItemHasImplicitMouseGrab) {
!mouseGrabberItems.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
lastMouseGrabb...licitMouseGrabDescription
TRUEnever evaluated
FALSEnever evaluated
0
6132 QGraphicsItem *item = mouseGrabberItems.constLast();-
6133 if (item->isBlockedByModalPanel())
item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6134 ungrabMouse(item, /*itemIsDying =*/ false);
never executed: ungrabMouse(item, false);
0
6135 }
never executed: end of block
0
6136-
6137 QEvent windowBlockedEvent(QEvent::WindowBlocked);-
6138 QEvent windowUnblockedEvent(QEvent::WindowUnblocked);-
6139 for (int i = 0; i < items.count(); ++i) {
i < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
6140 QGraphicsItem *item = items.at(i);-
6141 if (item->isPanel()) {
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6142 if (!blockedPanels.contains(item) && item->isBlockedByModalPanel()) {
!blockedPanels.contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6143 // send QEvent::WindowBlocked to newly blocked panels-
6144 sendEvent(item, &windowBlockedEvent);-
6145 } else if (blockedPanels.contains(item) && !item->isBlockedByModalPanel()) {
never executed: end of block
blockedPanels.contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
!item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6146 // send QEvent::WindowUnblocked to unblocked panels when downgrading-
6147 // a panel from SceneModal to PanelModal-
6148 sendEvent(item, &windowUnblockedEvent);-
6149 }
never executed: end of block
0
6150 }
never executed: end of block
0
6151 }
never executed: end of block
0
6152}
never executed: end of block
0
6153-
6154void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel)-
6155{-
6156 Q_Q(QGraphicsScene);-
6157 Q_ASSERT(panel && panel->isPanel());-
6158-
6159 QSet<QGraphicsItem *> blockedPanels;-
6160 QList<QGraphicsItem *> items = q->items(); // ### same as above-
6161 for (int i = 0; i < items.count(); ++i) {
i < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
6162 QGraphicsItem *item = items.at(i);-
6163 if (item->isPanel() && item->isBlockedByModalPanel())
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6164 blockedPanels.insert(item);
never executed: blockedPanels.insert(item);
0
6165 }
never executed: end of block
0
6166-
6167 modalPanels.removeAll(panel);-
6168-
6169 QEvent e(QEvent::WindowUnblocked);-
6170 for (int i = 0; i < items.count(); ++i) {
i < items.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
6171 QGraphicsItem *item = items.at(i);-
6172 if (item->isPanel() && blockedPanels.contains(item) && !item->isBlockedByModalPanel())
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
blockedPanels.contains(item)Description
TRUEnever evaluated
FALSEnever evaluated
!item->isBlockedByModalPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6173 sendEvent(item, &e);
never executed: sendEvent(item, &e);
0
6174 }
never executed: end of block
0
6175-
6176 // send GraphicsSceneHoverEnter events to newly unblocked items-
6177 QGraphicsSceneHoverEvent hoverEvent;-
6178 hoverEvent.setScenePos(lastSceneMousePos);-
6179 dispatchHoverEvent(&hoverEvent);-
6180}
never executed: end of block
0
6181-
6182#ifndef QT_NO_GESTURES-
6183void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures,-
6184 Qt::GestureFlag flag,-
6185 QHash<QGraphicsObject *, QSet<QGesture *> > *targets,-
6186 QSet<QGraphicsObject *> *itemsSet,-
6187 QSet<QGesture *> *normal,-
6188 QSet<QGesture *> *conflicts)-
6189{-
6190 QSet<QGesture *> normalGestures; // that are not in conflicted state.-
6191 for (QGesture *gesture : gestures) {-
6192 if (!gesture->hasHotSpot())
!gesture->hasHotSpot()Description
TRUEnever evaluated
FALSEnever evaluated
0
6193 continue;
never executed: continue;
0
6194 const Qt::GestureType gestureType = gesture->gestureType();-
6195 QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0);-
6196 for (int j = 0; j < items.size(); ++j) {
j < items.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
6197 QGraphicsItem *item = items.at(j);-
6198-
6199 // Check if the item is blocked by a modal panel and use it as-
6200 // a target instead of this item.-
6201 (void) item->isBlockedByModalPanel(&item);-
6202-
6203 if (QGraphicsObject *itemobj = item->toGraphicsObject()) {
QGraphicsObjec...aphicsObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
6204 QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();-
6205 QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it =-
6206 d->gestureContext.constFind(gestureType);-
6207 if (it != d->gestureContext.constEnd() && (!flag || (it.value() & flag))) {
it != d->gestu...ext.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
!flagDescription
TRUEnever evaluated
FALSEnever evaluated
(it.value() & flag)Description
TRUEnever evaluated
FALSEnever evaluated
0
6208 if (normalGestures.contains(gesture)) {
normalGestures...tains(gesture)Description
TRUEnever evaluated
FALSEnever evaluated
0
6209 normalGestures.remove(gesture);-
6210 if (conflicts)
conflictsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6211 conflicts->insert(gesture);
never executed: conflicts->insert(gesture);
0
6212 } else {
never executed: end of block
0
6213 normalGestures.insert(gesture);-
6214 }
never executed: end of block
0
6215 if (targets)
targetsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6216 (*targets)[itemobj].insert(gesture);
never executed: (*targets)[itemobj].insert(gesture);
0
6217 if (itemsSet)
itemsSetDescription
TRUEnever evaluated
FALSEnever evaluated
0
6218 (*itemsSet).insert(itemobj);
never executed: (*itemsSet).insert(itemobj);
0
6219 }
never executed: end of block
0
6220 }
never executed: end of block
0
6221 // Don't propagate through panels.-
6222 if (item->isPanel())
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6223 break;
never executed: break;
0
6224 }
never executed: end of block
0
6225 }
never executed: end of block
0
6226 if (normal)
normalDescription
TRUEnever evaluated
FALSEnever evaluated
0
6227 *normal = normalGestures;
never executed: *normal = normalGestures;
0
6228}
never executed: end of block
0
6229-
6230void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)-
6231{-
6232 QWidget *viewport = event->widget();-
6233 if (!viewport)
!viewportDescription
TRUEnever evaluated
FALSEnever evaluated
0
6234 return;
never executed: return;
0
6235 QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport->parent());-
6236 if (!graphicsView)
!graphicsViewDescription
TRUEnever evaluated
FALSEnever evaluated
0
6237 return;
never executed: return;
0
6238-
6239 const QList<QGesture *> allGestures = event->gestures();-
6240 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
dead code: QMessageLogger(__FILE__, 6240, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Gestures:" << allGestures;
-
6241 << "Gestures:" << allGestures;
dead code: QMessageLogger(__FILE__, 6240, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Gestures:" << allGestures;
-
6242-
6243 QSet<QGesture *> startedGestures;-
6244 QPoint delta = viewport->mapFromGlobal(QPoint());-
6245 QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y())-
6246 * graphicsView->viewportTransform().inverted();-
6247 for (QGesture *gesture : allGestures) {-
6248 // cache scene coordinates of the hot spot-
6249 if (gesture->hasHotSpot()) {
gesture->hasHotSpot()Description
TRUEnever evaluated
FALSEnever evaluated
0
6250 gesture->d_func()->sceneHotSpot = toScene.map(gesture->hotSpot());-
6251 } else {
never executed: end of block
0
6252 gesture->d_func()->sceneHotSpot = QPointF();-
6253 }
never executed: end of block
0
6254-
6255 QGraphicsObject *target = gestureTargets.value(gesture, 0);-
6256 if (!target) {
!targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
6257 // when we are not in started mode but don't have a target-
6258 // then the only one interested in gesture is the view/scene-
6259 if (gesture->state() == Qt::GestureStarted)
gesture->state...GestureStartedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6260 startedGestures.insert(gesture);
never executed: startedGestures.insert(gesture);
0
6261 }
never executed: end of block
0
6262 }
never executed: end of block
0
6263-
6264 if (!startedGestures.isEmpty()) {
!startedGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6265 QSet<QGesture *> normalGestures; // that have just one target-
6266 QSet<QGesture *> conflictedGestures; // that have multiple possible targets-
6267 gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0,-
6268 &normalGestures, &conflictedGestures);-
6269 cachedTargetItems = cachedItemGestures.keys();-
6270 std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);-
6271 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
dead code: QMessageLogger(__FILE__, 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures;
-
6272 << "Normal gestures:" << normalGestures
dead code: QMessageLogger(__FILE__, 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures;
-
6273 << "Conflicting gestures:" << conflictedGestures;
dead code: QMessageLogger(__FILE__, 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures;
-
6274-
6275 // deliver conflicted gestures as override events AND remember-
6276 // initial gesture targets-
6277 if (!conflictedGestures.isEmpty()) {
!conflictedGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6278 for (int i = 0; i < cachedTargetItems.size(); ++i) {
i < cachedTargetItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
6279 QPointer<QGraphicsObject> item = cachedTargetItems.at(i);-
6280-
6281 // get gestures to deliver to the current item-
6282 const QSet<QGesture *> gestures = conflictedGestures & cachedItemGestures.value(item.data());-
6283 if (gestures.isEmpty())
gestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6284 continue;
never executed: continue;
0
6285-
6286 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
dead code: QMessageLogger(__FILE__, 6286, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures;
-
6287 << "delivering override to"
dead code: QMessageLogger(__FILE__, 6286, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures;
-
6288 << item.data() << gestures;
dead code: QMessageLogger(__FILE__, 6286, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures;
-
6289 // send gesture override-
6290 QGestureEvent ev(gestures.toList());-
6291 ev.t = QEvent::GestureOverride;-
6292 ev.setWidget(event->widget());-
6293 // mark event and individual gestures as ignored-
6294 ev.ignore();-
6295 for (QGesture *g : gestures)-
6296 ev.setAccepted(g, false);
never executed: ev.setAccepted(g, false);
0
6297 sendEvent(item.data(), &ev);-
6298 // mark all accepted gestures to deliver them as normal gesture events-
6299 for (QGesture *g : gestures) {-
6300 if (ev.isAccepted() || ev.isAccepted(g)) {
ev.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
ev.isAccepted(g)Description
TRUEnever evaluated
FALSEnever evaluated
0
6301 conflictedGestures.remove(g);-
6302 // mark the item as a gesture target-
6303 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6304 gestureTargets.insert(g, item.data());-
6305 QHash<QGraphicsObject *, QSet<QGesture *> >::iterator it, e;-
6306 it = cachedItemGestures.begin();-
6307 e = cachedItemGestures.end();-
6308 for(; it != e; ++it)
it != eDescription
TRUEnever evaluated
FALSEnever evaluated
0
6309 it.value().remove(g);
never executed: it.value().remove(g);
0
6310 cachedItemGestures[item.data()].insert(g);-
6311 }
never executed: end of block
0
6312 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
dead code: QMessageLogger(__FILE__, 6312, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data();
-
6313 << "override was accepted:"
dead code: QMessageLogger(__FILE__, 6312, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data();
-
6314 << g << item.data();
dead code: QMessageLogger(__FILE__, 6312, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data();
-
6315 }
never executed: end of block
0
6316 // remember the first item that received the override event-
6317 // as it most likely become a target if no one else accepts-
6318 // the override event-
6319 if (!gestureTargets.contains(g) && item)
!gestureTargets.contains(g)Description
TRUEnever evaluated
FALSEnever evaluated
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6320 gestureTargets.insert(g, item.data());
never executed: gestureTargets.insert(g, item.data());
0
6321-
6322 }
never executed: end of block
0
6323 if (conflictedGestures.isEmpty())
conflictedGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6324 break;
never executed: break;
0
6325 }
never executed: end of block
0
6326 }
never executed: end of block
0
6327 // remember the initial target item for each gesture that was not in-
6328 // the conflicted state.-
6329 if (!normalGestures.isEmpty()) {
!normalGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6330 for (int i = 0; i < cachedTargetItems.size() && !normalGestures.isEmpty(); ++i) {
i < cachedTargetItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
!normalGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6331 QGraphicsObject *item = cachedTargetItems.at(i);-
6332-
6333 // get gestures to deliver to the current item-
6334 const auto gestures = cachedItemGestures.value(item);-
6335 for (QGesture *g : gestures) {-
6336 if (!gestureTargets.contains(g)) {
!gestureTargets.contains(g)Description
TRUEnever evaluated
FALSEnever evaluated
0
6337 gestureTargets.insert(g, item);-
6338 normalGestures.remove(g);-
6339 }
never executed: end of block
0
6340 }
never executed: end of block
0
6341 }
never executed: end of block
0
6342 }
never executed: end of block
0
6343 }
never executed: end of block
0
6344-
6345-
6346 // deliver all gesture events-
6347 QSet<QGesture *> undeliveredGestures;-
6348 QSet<QGesture *> parentPropagatedGestures;-
6349 for (QGesture *gesture : allGestures) {-
6350 if (QGraphicsObject *target = gestureTargets.value(gesture, 0)) {
QGraphicsObjec...ue(gesture, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
6351 cachedItemGestures[target].insert(gesture);-
6352 cachedTargetItems.append(target);-
6353 undeliveredGestures.insert(gesture);-
6354 QGraphicsItemPrivate *d = target->QGraphicsItem::d_func();-
6355 const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType());-
6356 if (flags & Qt::IgnoredGesturesPropagateToParent)
flags & Qt::Ig...pagateToParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
6357 parentPropagatedGestures.insert(gesture);
never executed: parentPropagatedGestures.insert(gesture);
0
6358 } else {
never executed: end of block
0
6359 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
dead code: QMessageLogger(__FILE__, 6359, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "no target for" << gesture << "at" << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
-
6360 << "no target for" << gesture << "at"
dead code: QMessageLogger(__FILE__, 6359, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "no target for" << gesture << "at" << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
-
6361 << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
dead code: QMessageLogger(__FILE__, 6359, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "no target for" << gesture << "at" << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
-
6362 }
never executed: end of block
0
6363 }-
6364 std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);-
6365 for (int i = 0; i < cachedTargetItems.size(); ++i) {
i < cachedTargetItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
6366 QPointer<QGraphicsObject> receiver = cachedTargetItems.at(i);-
6367 QSet<QGesture *> gestures =-
6368 undeliveredGestures & cachedItemGestures.value(receiver.data());-
6369 gestures -= cachedAlreadyDeliveredGestures.value(receiver.data());-
6370-
6371 if (gestures.isEmpty())
gestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6372 continue;
never executed: continue;
0
6373-
6374 cachedAlreadyDeliveredGestures[receiver.data()] += gestures;-
6375 const bool isPanel = receiver.data()->isPanel();-
6376-
6377 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
dead code: QMessageLogger(__FILE__, 6377, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures;
-
6378 << "delivering to"
dead code: QMessageLogger(__FILE__, 6377, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures;
-
6379 << receiver.data() << gestures;
dead code: QMessageLogger(__FILE__, 6377, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures;
-
6380 QGestureEvent ev(gestures.toList());-
6381 ev.setWidget(event->widget());-
6382 sendEvent(receiver.data(), &ev);-
6383 QSet<QGesture *> ignoredGestures;-
6384 foreach (QGesture *g, gestures) {-
6385 if (!ev.isAccepted() && !ev.isAccepted(g)) {
!ev.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
!ev.isAccepted(g)Description
TRUEnever evaluated
FALSEnever evaluated
0
6386 // if the gesture was ignored by its target, we will update the-
6387 // targetItems list with a possible target items (items that-
6388 // want to receive partial gestures).-
6389 // ### won't work if the target was destroyed in the event-
6390 // we will just stop delivering it.-
6391 if (receiver && receiver.data() == gestureTargets.value(g, 0))
receiverDescription
TRUEnever evaluated
FALSEnever evaluated
receiver.data(...ts.value(g, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
6392 ignoredGestures.insert(g);
never executed: ignoredGestures.insert(g);
0
6393 } else {
never executed: end of block
0
6394 if (receiver && g->state() == Qt::GestureStarted) {
receiverDescription
TRUEnever evaluated
FALSEnever evaluated
g->state() == ...GestureStartedDescription
TRUEnever evaluated
FALSEnever evaluated
0
6395 // someone accepted the propagated initial GestureStarted-
6396 // event, let it be the new target for all following events.-
6397 gestureTargets[g] = receiver.data();-
6398 }
never executed: end of block
0
6399 undeliveredGestures.remove(g);-
6400 }
never executed: end of block
0
6401 }-
6402 if (undeliveredGestures.isEmpty())
undeliveredGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6403 break;
never executed: break;
0
6404-
6405 // ignoredGestures list is only filled when delivering to the gesture-
6406 // target item, so it is safe to assume item == target.-
6407 if (!ignoredGestures.isEmpty() && !isPanel) {
!ignoredGestures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!isPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
6408 // look for new potential targets for gestures that were ignored-
6409 // and should be propagated.-
6410-
6411 QSet<QGraphicsObject *> targetsSet = cachedTargetItems.toSet();-
6412-
6413 if (receiver) {
receiverDescription
TRUEnever evaluated
FALSEnever evaluated
0
6414 // first if the gesture should be propagated to parents only-
6415 for (QSet<QGesture *>::iterator it = ignoredGestures.begin();-
6416 it != ignoredGestures.end();) {
it != ignoredGestures.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
6417 if (parentPropagatedGestures.contains(*it)) {
parentPropagat....contains(*it)Description
TRUEnever evaluated
FALSEnever evaluated
0
6418 QGesture *gesture = *it;-
6419 const Qt::GestureType gestureType = gesture->gestureType();-
6420 QGraphicsItem *item = receiver.data();-
6421 while (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6422 if (QGraphicsObject *obj = item->toGraphicsObject()) {
QGraphicsObjec...aphicsObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
6423 if (item->d_func()->gestureContext.contains(gestureType)) {
item->d_func()...s(gestureType)Description
TRUEnever evaluated
FALSEnever evaluated
0
6424 targetsSet.insert(obj);-
6425 cachedItemGestures[obj].insert(gesture);-
6426 }
never executed: end of block
0
6427 }
never executed: end of block
0
6428 if (item->isPanel())
item->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6429 break;
never executed: break;
0
6430 item = item->parentItem();-
6431 }
never executed: end of block
0
6432-
6433 it = ignoredGestures.erase(it);-
6434 continue;
never executed: continue;
0
6435 }-
6436 ++it;-
6437 }
never executed: end of block
0
6438 }
never executed: end of block
0
6439-
6440 gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures,-
6441 &cachedItemGestures, &targetsSet, 0, 0);-
6442-
6443 cachedTargetItems = targetsSet.toList();-
6444 std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);-
6445 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
dead code: QMessageLogger(__FILE__, 6445, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "new targets:" << cachedTargetItems;
-
6446 << "new targets:" << cachedTargetItems;
dead code: QMessageLogger(__FILE__, 6445, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "new targets:" << cachedTargetItems;
-
6447 i = -1; // start delivery again-
6448 continue;
never executed: continue;
0
6449 }-
6450 }
never executed: end of block
0
6451-
6452 foreach (QGesture *g, startedGestures) {-
6453 if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) {
g->gestureCanc...elAllInContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
6454 DEBUG() << "lets try to cancel some";
dead code: QMessageLogger(__FILE__, 6454, __PRETTY_FUNCTION__).debug() << "lets try to cancel some";
-
6455 // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them-
6456 cancelGesturesForChildren(g);-
6457 }
never executed: end of block
0
6458 }
never executed: end of block
0
6459-
6460 // forget about targets for gestures that have ended-
6461 for (QGesture *g : allGestures) {-
6462 switch (g->state()) {-
6463 case Qt::GestureFinished:
never executed: case Qt::GestureFinished:
0
6464 case Qt::GestureCanceled:
never executed: case Qt::GestureCanceled:
0
6465 gestureTargets.remove(g);-
6466 break;
never executed: break;
0
6467 default:
never executed: default:
0
6468 break;
never executed: break;
0
6469 }-
6470 }-
6471-
6472 cachedTargetItems.clear();-
6473 cachedItemGestures.clear();-
6474 cachedAlreadyDeliveredGestures.clear();-
6475}
never executed: end of block
0
6476-
6477void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)-
6478{-
6479 Q_ASSERT(original);-
6480 QGraphicsItem *originalItem = gestureTargets.value(original);-
6481 if (originalItem == 0) // we only act on accepted gestures, which implies it has a target.
originalItem == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6482 return;
never executed: return;
0
6483-
6484 // iterate over all active gestures and for each find the owner-
6485 // if the owner is part of our sub-hierarchy, cancel it.-
6486-
6487 QSet<QGesture *> canceledGestures;-
6488 QHash<QGesture *, QGraphicsObject *>::Iterator iter = gestureTargets.begin();-
6489 while (iter != gestureTargets.end()) {
iter != gestureTargets.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
6490 QGraphicsObject *item = iter.value();-
6491 // note that we don't touch the gestures for our originalItem-
6492 if (item != originalItem && originalItem->isAncestorOf(item)) {
item != originalItemDescription
TRUEnever evaluated
FALSEnever evaluated
originalItem->...cestorOf(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
6493 DEBUG() << " found a gesture to cancel" << iter.key();
dead code: QMessageLogger(__FILE__, 6493, __PRETTY_FUNCTION__).debug() << " found a gesture to cancel" << iter.key();
-
6494 iter.key()->d_func()->state = Qt::GestureCanceled;-
6495 canceledGestures << iter.key();-
6496 }
never executed: end of block
0
6497 ++iter;-
6498 }
never executed: end of block
0
6499-
6500 // sort them per target item by cherry picking from almostCanceledGestures and delivering-
6501 QSet<QGesture *> almostCanceledGestures = canceledGestures;-
6502 QSet<QGesture *>::Iterator setIter;-
6503 while (!almostCanceledGestures.isEmpty()) {
!almostCancele...ures.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
6504 QGraphicsObject *target = 0;-
6505 QSet<QGesture*> gestures;-
6506 setIter = almostCanceledGestures.begin();-
6507 // sort per target item-
6508 while (setIter != almostCanceledGestures.end()) {
setIter != alm...Gestures.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
6509 QGraphicsObject *item = gestureTargets.value(*setIter);-
6510 if (target == 0)
target == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6511 target = item;
never executed: target = item;
0
6512 if (target == item) {
target == itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6513 gestures << *setIter;-
6514 setIter = almostCanceledGestures.erase(setIter);-
6515 } else {
never executed: end of block
0
6516 ++setIter;-
6517 }
never executed: end of block
0
6518 }-
6519 Q_ASSERT(target);-
6520-
6521 const QList<QGesture *> list = gestures.toList();-
6522 QGestureEvent ev(list);-
6523 sendEvent(target, &ev);-
6524-
6525 if (!ev.isAccepted()) {
!ev.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
6526 for (QGesture *g : list) {-
6527-
6528 if (ev.isAccepted(g))
ev.isAccepted(g)Description
TRUEnever evaluated
FALSEnever evaluated
0
6529 continue;
never executed: continue;
0
6530-
6531 if (!g->hasHotSpot())
!g->hasHotSpot()Description
TRUEnever evaluated
FALSEnever evaluated
0
6532 continue;
never executed: continue;
0
6533-
6534 QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0);-
6535 for (int j = 0; j < items.size(); ++j) {
j < items.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
6536 QGraphicsObject *item = items.at(j)->toGraphicsObject();-
6537 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6538 continue;
never executed: continue;
0
6539 QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();-
6540 if (d->gestureContext.contains(g->gestureType())) {
d->gestureCont...gestureType())Description
TRUEnever evaluated
FALSEnever evaluated
0
6541 QList<QGesture *> list;-
6542 list << g;-
6543 QGestureEvent ev(list);-
6544 sendEvent(item, &ev);-
6545 if (ev.isAccepted() || ev.isAccepted(g))
ev.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
ev.isAccepted(g)Description
TRUEnever evaluated
FALSEnever evaluated
0
6546 break; // successfully delivered
never executed: break;
0
6547 }
never executed: end of block
0
6548 }
never executed: end of block
0
6549 }
never executed: end of block
0
6550 }
never executed: end of block
0
6551 }
never executed: end of block
0
6552-
6553 QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;-
6554 Q_ASSERT(gestureManager); // it would be very odd if we got called without a manager.-
6555 for (setIter = canceledGestures.begin(); setIter != canceledGestures.end(); ++setIter) {
setIter != can...Gestures.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
6556 gestureManager->recycle(*setIter);-
6557 gestureTargets.remove(*setIter);-
6558 }
never executed: end of block
0
6559}
never executed: end of block
0
6560-
6561void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture)-
6562{-
6563 (void)QGestureManager::instance(); // create a gesture manager-
6564 if (!grabbedGestures[gesture]++) {
!grabbedGestures[gesture]++Description
TRUEnever evaluated
FALSEnever evaluated
0
6565 foreach (QGraphicsView *view, views)-
6566 view->viewport()->grabGesture(gesture);
never executed: view->viewport()->grabGesture(gesture);
0
6567 }
never executed: end of block
0
6568}
never executed: end of block
0
6569-
6570void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType gesture)-
6571{-
6572 // we know this can only be an object-
6573 Q_ASSERT(item->d_ptr->isObject);-
6574 QGraphicsObject *obj = static_cast<QGraphicsObject *>(item);-
6575 QGestureManager::instance()->cleanupCachedGestures(obj, gesture);-
6576 if (!--grabbedGestures[gesture]) {
!--grabbedGestures[gesture]Description
TRUEnever evaluated
FALSEnever evaluated
0
6577 foreach (QGraphicsView *view, views)-
6578 view->viewport()->ungrabGesture(gesture);
never executed: view->viewport()->ungrabGesture(gesture);
0
6579 }
never executed: end of block
0
6580}
never executed: end of block
0
6581#endif // QT_NO_GESTURES-
6582-
6583QT_END_NAMESPACE-
6584-
6585#include "moc_qgraphicsscene.cpp"-
6586-
6587#endif // QT_NO_GRAPHICSVIEW-
Source codeSwitch to Preprocessed file

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