| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicsscene.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); | - | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 13 | { | - | ||||||||||||||||||||||||
| 14 | hover->setWidget(mouseEvent->widget()); | - | ||||||||||||||||||||||||
| 15 | hover->setPos(mouseEvent->pos()); | - | ||||||||||||||||||||||||
| 16 | hover->setScenePos(mouseEvent->scenePos()); | - | ||||||||||||||||||||||||
| 17 | hover->setScreenPos(mouseEvent->screenPos()); | - | ||||||||||||||||||||||||
| 18 | hover->setLastPos(mouseEvent->lastPos()); | - | ||||||||||||||||||||||||
| 19 | hover->setLastScenePos(mouseEvent->lastScenePos()); | - | ||||||||||||||||||||||||
| 20 | hover->setLastScreenPos(mouseEvent->lastScreenPos()); | - | ||||||||||||||||||||||||
| 21 | hover->setModifiers(mouseEvent->modifiers()); | - | ||||||||||||||||||||||||
| 22 | hover->setAccepted(mouseEvent->isAccepted()); | - | ||||||||||||||||||||||||
| 23 | } | - | ||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||
| 28 | QGraphicsScenePrivate::QGraphicsScenePrivate() | - | ||||||||||||||||||||||||
| 29 | : indexMethod(QGraphicsScene::BspTreeIndex), | - | ||||||||||||||||||||||||
| 30 | index(0), | - | ||||||||||||||||||||||||
| 31 | lastItemCount(0), | - | ||||||||||||||||||||||||
| 32 | hasSceneRect(false), | - | ||||||||||||||||||||||||
| 33 | dirtyGrowingItemsBoundingRect(true), | - | ||||||||||||||||||||||||
| 34 | updateAll(false), | - | ||||||||||||||||||||||||
| 35 | calledEmitUpdated(false), | - | ||||||||||||||||||||||||
| 36 | processDirtyItemsEmitted(false), | - | ||||||||||||||||||||||||
| 37 | needSortTopLevelItems(true), | - | ||||||||||||||||||||||||
| 38 | holesInTopLevelSiblingIndex(false), | - | ||||||||||||||||||||||||
| 39 | topLevelSequentialOrdering(true), | - | ||||||||||||||||||||||||
| 40 | scenePosDescendantsUpdatePending(false), | - | ||||||||||||||||||||||||
| 41 | stickyFocus(false), | - | ||||||||||||||||||||||||
| 42 | hasFocus(false), | - | ||||||||||||||||||||||||
| 43 | lastMouseGrabberItemHasImplicitMouseGrab(false), | - | ||||||||||||||||||||||||
| 44 | allItemsIgnoreHoverEvents(true), | - | ||||||||||||||||||||||||
| 45 | allItemsUseDefaultCursor(true), | - | ||||||||||||||||||||||||
| 46 | painterStateProtection(true), | - | ||||||||||||||||||||||||
| 47 | sortCacheEnabled(false), | - | ||||||||||||||||||||||||
| 48 | allItemsIgnoreTouchEvents(true), | - | ||||||||||||||||||||||||
| 49 | minimumRenderSize(0.0), | - | ||||||||||||||||||||||||
| 50 | selectionChanging(0), | - | ||||||||||||||||||||||||
| 51 | rectAdjust(2), | - | ||||||||||||||||||||||||
| 52 | focusItem(0), | - | ||||||||||||||||||||||||
| 53 | lastFocusItem(0), | - | ||||||||||||||||||||||||
| 54 | passiveFocusItem(0), | - | ||||||||||||||||||||||||
| 55 | tabFocusFirst(0), | - | ||||||||||||||||||||||||
| 56 | activePanel(0), | - | ||||||||||||||||||||||||
| 57 | lastActivePanel(0), | - | ||||||||||||||||||||||||
| 58 | activationRefCount(0), | - | ||||||||||||||||||||||||
| 59 | childExplicitActivation(0), | - | ||||||||||||||||||||||||
| 60 | lastMouseGrabberItem(0), | - | ||||||||||||||||||||||||
| 61 | dragDropItem(0), | - | ||||||||||||||||||||||||
| 62 | enterWidget(0), | - | ||||||||||||||||||||||||
| 63 | lastDropAction(Qt::IgnoreAction), | - | ||||||||||||||||||||||||
| 64 | style(0) | - | ||||||||||||||||||||||||
| 65 | { | - | ||||||||||||||||||||||||
| 66 | } | - | ||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | void QGraphicsScenePrivate::init() | - | ||||||||||||||||||||||||
| 72 | { | - | ||||||||||||||||||||||||
| 73 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | index = new QGraphicsSceneBspTreeIndex(q); | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | changedSignalIndex = signalIndex("changed(QList<QRectF>)"); | - | ||||||||||||||||||||||||
| 79 | processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()"); | - | ||||||||||||||||||||||||
| 80 | polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()"); | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->scene_list.append(q); | - | ||||||||||||||||||||||||
| 83 | q->update(); | - | ||||||||||||||||||||||||
| 84 | } | - | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | QGraphicsScenePrivate *QGraphicsScenePrivate::get(QGraphicsScene *q) | - | ||||||||||||||||||||||||
| 90 | { | - | ||||||||||||||||||||||||
| 91 | return q->d_func(); | - | ||||||||||||||||||||||||
| 92 | } | - | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | void QGraphicsScenePrivate::_q_emitUpdated() | - | ||||||||||||||||||||||||
| 95 | { | - | ||||||||||||||||||||||||
| 96 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 97 | calledEmitUpdated = false; | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | if (dirtyGrowingItemsBoundingRect) { | - | ||||||||||||||||||||||||
| 100 | if (!hasSceneRect) { | - | ||||||||||||||||||||||||
| 101 | const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect; | - | ||||||||||||||||||||||||
| 102 | growingItemsBoundingRect |= q->itemsBoundingRect(); | - | ||||||||||||||||||||||||
| 103 | if (oldGrowingItemsBoundingRect != growingItemsBoundingRect) | - | ||||||||||||||||||||||||
| 104 | q->sceneRectChanged(growingItemsBoundingRect); | - | ||||||||||||||||||||||||
| 105 | } | - | ||||||||||||||||||||||||
| 106 | dirtyGrowingItemsBoundingRect = false; | - | ||||||||||||||||||||||||
| 107 | } | - | ||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | if (isSignalConnected(changedSignalIndex)) { | - | ||||||||||||||||||||||||
| 114 | for (int i = 0; i < views.size(); ++i) { | - | ||||||||||||||||||||||||
| 115 | QGraphicsView *view = views.at(i); | - | ||||||||||||||||||||||||
| 116 | if (!view->d_func()->connectedToScene) { | - | ||||||||||||||||||||||||
| 117 | view->d_func()->connectedToScene = true; | - | ||||||||||||||||||||||||
| 118 | q->connect(q, qFlagLocation("2""changed(QList<QRectF>)" "\0" __FILE__ ":" "363""370"), | - | ||||||||||||||||||||||||
| 119 | views.at(i), qFlagLocation("1""updateScene(QList<QRectF>)" "\0" __FILE__ ":" "364""371")); | - | ||||||||||||||||||||||||
| 120 | } | - | ||||||||||||||||||||||||
| 121 | } | - | ||||||||||||||||||||||||
| 122 | } else { | - | ||||||||||||||||||||||||
| 123 | if (views.isEmpty()) { | - | ||||||||||||||||||||||||
| 124 | updateAll = false; | - | ||||||||||||||||||||||||
| 125 | return; | - | ||||||||||||||||||||||||
| 126 | } | - | ||||||||||||||||||||||||
| 127 | for (int i = 0; i < views.size(); ++i) | - | ||||||||||||||||||||||||
| 128 | views.at(i)->d_func()->processPendingUpdates(); | - | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | for (int i = 0; i < views.size(); ++i) | - | ||||||||||||||||||||||||
| 131 | views.at(i)->d_func()->dispatchPendingUpdateRequests(); | - | ||||||||||||||||||||||||
| 132 | return; | - | ||||||||||||||||||||||||
| 133 | } | - | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | QList<QRectF> oldUpdatedRects; | - | ||||||||||||||||||||||||
| 137 | oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects; | - | ||||||||||||||||||||||||
| 138 | updateAll = false; | - | ||||||||||||||||||||||||
| 139 | updatedRects.clear(); | - | ||||||||||||||||||||||||
| 140 | q->changed(oldUpdatedRects); | - | ||||||||||||||||||||||||
| 141 | } | - | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||
| 148 | void QGraphicsScenePrivate::registerTopLevelItem(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 149 | { | - | ||||||||||||||||||||||||
| 150 | ensureSequentialTopLevelSiblingIndexes(); | - | ||||||||||||||||||||||||
| 151 | needSortTopLevelItems = true; | - | ||||||||||||||||||||||||
| 152 | item->d_ptr->siblingIndex = topLevelItems.size(); | - | ||||||||||||||||||||||||
| 153 | topLevelItems.append(item); | - | ||||||||||||||||||||||||
| 154 | } | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 162 | { | - | ||||||||||||||||||||||||
| 163 | if (!holesInTopLevelSiblingIndex) | - | ||||||||||||||||||||||||
| 164 | holesInTopLevelSiblingIndex = item->d_ptr->siblingIndex != topLevelItems.size() - 1; | - | ||||||||||||||||||||||||
| 165 | if (topLevelSequentialOrdering && !holesInTopLevelSiblingIndex) | - | ||||||||||||||||||||||||
| 166 | topLevelItems.removeAt(item->d_ptr->siblingIndex); | - | ||||||||||||||||||||||||
| 167 | else | - | ||||||||||||||||||||||||
| 168 | topLevelItems.removeOne(item); | - | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | item->d_ptr->siblingIndex = -1; | - | ||||||||||||||||||||||||
| 173 | if (topLevelSequentialOrdering) | - | ||||||||||||||||||||||||
| 174 | topLevelSequentialOrdering = !holesInTopLevelSiblingIndex; | - | ||||||||||||||||||||||||
| 175 | } | - | ||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | void QGraphicsScenePrivate::_q_polishItems() | - | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | if (unpolishedItems.isEmpty()) | - | ||||||||||||||||||||||||
| 183 | return; | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | const QVariant booleanTrueVariant(true); | - | ||||||||||||||||||||||||
| 186 | QGraphicsItem *item = 0; | - | ||||||||||||||||||||||||
| 187 | QGraphicsItemPrivate *itemd = 0; | - | ||||||||||||||||||||||||
| 188 | const int oldUnpolishedCount = unpolishedItems.count(); | - | ||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||
| 190 | for (int i = 0; i < oldUnpolishedCount; ++i) { | - | ||||||||||||||||||||||||
| 191 | item = unpolishedItems.at(i); | - | ||||||||||||||||||||||||
| 192 | if (!item) | - | ||||||||||||||||||||||||
| 193 | continue; | - | ||||||||||||||||||||||||
| 194 | itemd = item->d_ptr.data(); | - | ||||||||||||||||||||||||
| 195 | itemd->pendingPolish = false; | - | ||||||||||||||||||||||||
| 196 | if (!itemd->explicitlyHidden) { | - | ||||||||||||||||||||||||
| 197 | item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant); | - | ||||||||||||||||||||||||
| 198 | item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant); | - | ||||||||||||||||||||||||
| 199 | } | - | ||||||||||||||||||||||||
| 200 | if (itemd->isWidget) { | - | ||||||||||||||||||||||||
| 201 | QEvent event(QEvent::Polish); | - | ||||||||||||||||||||||||
| 202 | QApplication::sendEvent((QGraphicsWidget *)item, &event); | - | ||||||||||||||||||||||||
| 203 | } | - | ||||||||||||||||||||||||
| 204 | } | - | ||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||
| 206 | if (unpolishedItems.count() == oldUnpolishedCount) { | - | ||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||
| 208 | unpolishedItems.clear(); | - | ||||||||||||||||||||||||
| 209 | } else { | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | unpolishedItems.remove(0, oldUnpolishedCount); | - | ||||||||||||||||||||||||
| 212 | unpolishedItems.squeeze(); | - | ||||||||||||||||||||||||
| 213 | QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 214 | } | - | ||||||||||||||||||||||||
| 215 | } | - | ||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||
| 217 | void QGraphicsScenePrivate::_q_processDirtyItems() | - | ||||||||||||||||||||||||
| 218 | { | - | ||||||||||||||||||||||||
| 219 | processDirtyItemsEmitted = false; | - | ||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | if (updateAll) { | - | ||||||||||||||||||||||||
| 222 | ((!(calledEmitUpdated)) ? qt_assert("calledEmitUpdated",__FILE__,467474) : qt_noop()); | - | ||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | for (int i = 0; i < topLevelItems.size(); ++i) | - | ||||||||||||||||||||||||
| 226 | resetDirtyItem(topLevelItems.at(i), true); | - | ||||||||||||||||||||||||
| 227 | return; | - | ||||||||||||||||||||||||
| 228 | } | - | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | const bool wasPendingSceneUpdate = calledEmitUpdated; | - | ||||||||||||||||||||||||
| 231 | const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect; | - | ||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | for (int i = 0; i < topLevelItems.size(); ++i) | - | ||||||||||||||||||||||||
| 235 | processDirtyItemsRecursive(topLevelItems.at(i)); | - | ||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | dirtyGrowingItemsBoundingRect = false; | - | ||||||||||||||||||||||||
| 238 | if (!hasSceneRect && oldGrowingItemsBoundingRect != growingItemsBoundingRect) | - | ||||||||||||||||||||||||
| 239 | q_func()->sceneRectChanged(growingItemsBoundingRect); | - | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | if (wasPendingSceneUpdate) | - | ||||||||||||||||||||||||
| 242 | return; | - | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | for (int i = 0; i < views.size(); ++i) | - | ||||||||||||||||||||||||
| 245 | views.at(i)->d_func()->processPendingUpdates(); | - | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | if (calledEmitUpdated) { | - | ||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||
| 251 | _q_emitUpdated(); | - | ||||||||||||||||||||||||
| 252 | } | - | ||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||
| 255 | for (int i = 0; i < views.size(); ++i) | - | ||||||||||||||||||||||||
| 256 | views.at(i)->d_func()->dispatchPendingUpdateRequests(); | - | ||||||||||||||||||||||||
| 257 | } | - | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | void QGraphicsScenePrivate::setScenePosItemEnabled(QGraphicsItem *item, bool enabled) | - | ||||||||||||||||||||||||
| 263 | { | - | ||||||||||||||||||||||||
| 264 | QGraphicsItem *p = item->d_ptr->parent; | - | ||||||||||||||||||||||||
| 265 | while (p) { | - | ||||||||||||||||||||||||
| 266 | p->d_ptr->scenePosDescendants = enabled; | - | ||||||||||||||||||||||||
| 267 | p = p->d_ptr->parent; | - | ||||||||||||||||||||||||
| 268 | } | - | ||||||||||||||||||||||||
| 269 | if (!enabled && !scenePosDescendantsUpdatePending) { | - | ||||||||||||||||||||||||
| 270 | scenePosDescendantsUpdatePending = true; | - | ||||||||||||||||||||||||
| 271 | QMetaObject::invokeMethod(q_func(), "_q_updateScenePosDescendants", Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 272 | } | - | ||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | void QGraphicsScenePrivate::registerScenePosItem(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 279 | { | - | ||||||||||||||||||||||||
| 280 | scenePosItems.insert(item); | - | ||||||||||||||||||||||||
| 281 | setScenePosItemEnabled(item, true); | - | ||||||||||||||||||||||||
| 282 | } | - | ||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | void QGraphicsScenePrivate::unregisterScenePosItem(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 288 | { | - | ||||||||||||||||||||||||
| 289 | scenePosItems.remove(item); | - | ||||||||||||||||||||||||
| 290 | setScenePosItemEnabled(item, false); | - | ||||||||||||||||||||||||
| 291 | } | - | ||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||
| 296 | void QGraphicsScenePrivate::_q_updateScenePosDescendants() | - | ||||||||||||||||||||||||
| 297 | { | - | ||||||||||||||||||||||||
| 298 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(scenePosItems)>::type> _container_((scenePosItems)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 299 | QGraphicsItem *p = item->d_ptr->parent; | - | ||||||||||||||||||||||||
| 300 | while (p) { | - | ||||||||||||||||||||||||
| 301 | p->d_ptr->scenePosDescendants = 1; | - | ||||||||||||||||||||||||
| 302 | p = p->d_ptr->parent; | - | ||||||||||||||||||||||||
| 303 | } | - | ||||||||||||||||||||||||
| 304 | } | - | ||||||||||||||||||||||||
| 305 | scenePosDescendantsUpdatePending = false; | - | ||||||||||||||||||||||||
| 306 | } | - | ||||||||||||||||||||||||
| 307 | void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 308 | { | - | ||||||||||||||||||||||||
| 309 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | item->clearFocus(); | - | ||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | markDirty(item, QRectF(), false, false, | - | ||||||||||||||||||||||||
| 315 | false, true); | - | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | if (item->d_ptr->inDestructor) { | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | index->deleteItem(item); | - | ||||||||||||||||||||||||
| 320 | } else { | - | ||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||
| 323 | index->removeItem(item); | - | ||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||
| 325 | - | |||||||||||||||||||||||||
| 326 | item->d_ptr->clearSubFocus(); | - | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges) | - | ||||||||||||||||||||||||
| 329 | unregisterScenePosItem(item); | - | ||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | QGraphicsScene *oldScene = item->d_func()->scene; | - | ||||||||||||||||||||||||
| 332 | item->d_func()->scene = 0; | - | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | if (!item->d_ptr->inDestructor) { | - | ||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | for (int i = 0; i < item->d_ptr->children.size(); ++i) | - | ||||||||||||||||||||||||
| 339 | q->removeItem(item->d_ptr->children.at(i)); | - | ||||||||||||||||||||||||
| 340 | } | - | ||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | if (!item->d_ptr->inDestructor && !item->parentItem() && item->isWidget()) { | - | ||||||||||||||||||||||||
| 343 | QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
| 344 | widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0); | - | ||||||||||||||||||||||||
| 345 | } | - | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | item->d_ptr->resetFocusProxy(); | - | ||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||
| 351 | if (QGraphicsItem *parentItem = item->parentItem()) { | - | ||||||||||||||||||||||||
| 352 | if (parentItem->scene()) { | - | ||||||||||||||||||||||||
| 353 | ((!(parentItem->scene() == q)) ? qt_assert_x("QGraphicsScene::removeItem", "Parent item's scene is different from this item's scene", | - | ||||||||||||||||||||||||
| 354 | __FILE__ | - | ||||||||||||||||||||||||
| 355 | , | - | ||||||||||||||||||||||||
| 356 | 612619 | - | ||||||||||||||||||||||||
| 357 | ) : qt_noop()) | - | ||||||||||||||||||||||||
| 358 | ; | - | ||||||||||||||||||||||||
| 359 | item->setParentItem(0); | - | ||||||||||||||||||||||||
| 360 | } | - | ||||||||||||||||||||||||
| 361 | } else { | - | ||||||||||||||||||||||||
| 362 | unregisterTopLevelItem(item); | - | ||||||||||||||||||||||||
| 363 | } | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | if (item == focusItem) | - | ||||||||||||||||||||||||
| 367 | focusItem = 0; | - | ||||||||||||||||||||||||
| 368 | if (item == lastFocusItem) | - | ||||||||||||||||||||||||
| 369 | lastFocusItem = 0; | - | ||||||||||||||||||||||||
| 370 | if (item == passiveFocusItem) | - | ||||||||||||||||||||||||
| 371 | passiveFocusItem = 0; | - | ||||||||||||||||||||||||
| 372 | if (item == activePanel) { | - | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | activePanel = 0; | - | ||||||||||||||||||||||||
| 375 | } | - | ||||||||||||||||||||||||
| 376 | if (item == lastActivePanel) | - | ||||||||||||||||||||||||
| 377 | lastActivePanel = 0; | - | ||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | if (item == tabFocusFirst) { | - | ||||||||||||||||||||||||
| 381 | QGraphicsWidgetPrivate *wd = tabFocusFirst->d_func(); | - | ||||||||||||||||||||||||
| 382 | if (wd->focusNext && wd->focusNext != tabFocusFirst && wd->focusNext->scene() == q) | - | ||||||||||||||||||||||||
| 383 | tabFocusFirst = wd->focusNext; | - | ||||||||||||||||||||||||
| 384 | else | - | ||||||||||||||||||||||||
| 385 | tabFocusFirst = 0; | - | ||||||||||||||||||||||||
| 386 | } | - | ||||||||||||||||||||||||
| 387 | - | |||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | { | - | ||||||||||||||||||||||||
| 390 | QMap<int, QGraphicsItem *>::iterator it = itemForTouchPointId.begin(); | - | ||||||||||||||||||||||||
| 391 | while (it != itemForTouchPointId.end()) { | - | ||||||||||||||||||||||||
| 392 | if (it.value() == item) { | - | ||||||||||||||||||||||||
| 393 | sceneCurrentTouchPoints.remove(it.key()); | - | ||||||||||||||||||||||||
| 394 | it = itemForTouchPointId.erase(it); | - | ||||||||||||||||||||||||
| 395 | } else { | - | ||||||||||||||||||||||||
| 396 | ++it; | - | ||||||||||||||||||||||||
| 397 | } | - | ||||||||||||||||||||||||
| 398 | } | - | ||||||||||||||||||||||||
| 399 | } | - | ||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | ++selectionChanging; | - | ||||||||||||||||||||||||
| 403 | int oldSelectedItemsSize = selectedItems.size(); | - | ||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||
| 406 | selectedItems.remove(item); | - | ||||||||||||||||||||||||
| 407 | hoverItems.removeAll(item); | - | ||||||||||||||||||||||||
| 408 | cachedItemsUnderMouse.removeAll(item); | - | ||||||||||||||||||||||||
| 409 | if (item->d_ptr->pendingPolish) { | - | ||||||||||||||||||||||||
| 410 | const int unpolishedIndex = unpolishedItems.indexOf(item); | - | ||||||||||||||||||||||||
| 411 | if (unpolishedIndex != -1) | - | ||||||||||||||||||||||||
| 412 | unpolishedItems[unpolishedIndex] = 0; | - | ||||||||||||||||||||||||
| 413 | item->d_ptr->pendingPolish = false; | - | ||||||||||||||||||||||||
| 414 | } | - | ||||||||||||||||||||||||
| 415 | resetDirtyItem(item); | - | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||
| 418 | QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin(); | - | ||||||||||||||||||||||||
| 419 | while (iterator != sceneEventFilters.end()) { | - | ||||||||||||||||||||||||
| 420 | if (iterator.value() == item || iterator.key() == item) | - | ||||||||||||||||||||||||
| 421 | iterator = sceneEventFilters.erase(iterator); | - | ||||||||||||||||||||||||
| 422 | else | - | ||||||||||||||||||||||||
| 423 | ++iterator; | - | ||||||||||||||||||||||||
| 424 | } | - | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal) | - | ||||||||||||||||||||||||
| 427 | leaveModal(item); | - | ||||||||||||||||||||||||
| 428 | - | |||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||
| 430 | if (mouseGrabberItems.contains(item)) | - | ||||||||||||||||||||||||
| 431 | ungrabMouse(item, item->d_ptr->inDestructor); | - | ||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | if (keyboardGrabberItems.contains(item)) | - | ||||||||||||||||||||||||
| 435 | ungrabKeyboard(item, item->d_ptr->inDestructor); | - | ||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||
| 438 | if (item == lastMouseGrabberItem) | - | ||||||||||||||||||||||||
| 439 | lastMouseGrabberItem = 0; | - | ||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | if (item == dragDropItem) | - | ||||||||||||||||||||||||
| 443 | dragDropItem = 0; | - | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | --selectionChanging; | - | ||||||||||||||||||||||||
| 447 | if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize) | - | ||||||||||||||||||||||||
| 448 | q->selectionChanged(); | - | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||
| 451 | QHash<QGesture *, QGraphicsObject *>::iterator it; | - | ||||||||||||||||||||||||
| 452 | for (it = gestureTargets.begin(); it != gestureTargets.end();) { | - | ||||||||||||||||||||||||
| 453 | if (it.value() == item) | - | ||||||||||||||||||||||||
| 454 | it = gestureTargets.erase(it); | - | ||||||||||||||||||||||||
| 455 | else | - | ||||||||||||||||||||||||
| 456 | ++it; | - | ||||||||||||||||||||||||
| 457 | } | - | ||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||
| 459 | if (QGraphicsObject *dummy = item->toGraphicsObject()) { | - | ||||||||||||||||||||||||
| 460 | cachedTargetItems.removeOne(dummy); | - | ||||||||||||||||||||||||
| 461 | cachedItemGestures.remove(dummy); | - | ||||||||||||||||||||||||
| 462 | cachedAlreadyDeliveredGestures.remove(dummy); | - | ||||||||||||||||||||||||
| 463 | } | - | ||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||
| 465 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(item->d_ptr->gestureContext.keys())>::type> _container_((item->d_ptr->gestureContext.keys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (Qt::GestureType gesture = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
| 466 | ungrabGesture(item, gesture); | - | ||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||
| 468 | } | - | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent) | - | ||||||||||||||||||||||||
| 474 | { | - | ||||||||||||||||||||||||
| 475 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 476 | if (item
| 0 | ||||||||||||||||||||||||
| 477 | QMessageLogger(__FILE__, 731738, __PRETTY_FUNCTION__).warning("QGraphicsScene::setActivePanel: item %p must be part of this scene", | - | ||||||||||||||||||||||||
| 478 | item); | - | ||||||||||||||||||||||||
| 479 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 480 | } | - | ||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | q->setFocus(Qt::ActiveWindowFocusReason); | - | ||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | QGraphicsItem *panel = item
| 0 | ||||||||||||||||||||||||
| 487 | lastActivePanel = panel
| 0 | ||||||||||||||||||||||||
| 488 | if (panel == activePanel
| 0 | ||||||||||||||||||||||||
| 489 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||
| 491 | QGraphicsItem *oldFocusItem = focusItem; | - | ||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||
| 494 | if (activePanel
| 0 | ||||||||||||||||||||||||
| 495 | if (QGraphicsItem *fi = activePanel->focusItem()
| 0 | ||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||
| 497 | if (fi == q->focusItem()
| 0 | ||||||||||||||||||||||||
| 498 | setFocusItemHelper(0, Qt::ActiveWindowFocusReason, false); never executed: setFocusItemHelper(0, Qt::ActiveWindowFocusReason, false); | 0 | ||||||||||||||||||||||||
| 499 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||
| 501 | QEvent event(QEvent::WindowDeactivate); | - | ||||||||||||||||||||||||
| 502 | q->sendEvent(activePanel, &event); | - | ||||||||||||||||||||||||
| 503 | } never executed: else if (panelend of block
| 0 | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | const auto items = q->items(); | - | ||||||||||||||||||||||||
| 506 | QEvent event(QEvent::WindowDeactivate); | - | ||||||||||||||||||||||||
| 507 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(q->items())>::type> _container_((q->items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) { | - | ||||||||||||||||||||||||
| 508 | if (item->isVisible()
| 0 | ||||||||||||||||||||||||
| 509 | q->sendEvent(item, &event); never executed: q->sendEvent(item, &event); | 0 | ||||||||||||||||||||||||
| 510 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 511 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | activePanel = panel; | - | ||||||||||||||||||||||||
| 515 | QEvent event(QEvent::ActivationChange); | - | ||||||||||||||||||||||||
| 516 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | if (panel
| 0 | ||||||||||||||||||||||||
| 520 | QEvent event(QEvent::WindowActivate); | - | ||||||||||||||||||||||||
| 521 | q->sendEvent(panel, &event); | - | ||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||
| 525 | - | |||||||||||||||||||||||||
| 526 | if (QGraphicsItem *focusItem = panel->focusItem()
| 0 | ||||||||||||||||||||||||
| 527 | setFocusItemHelper(focusItem, Qt::ActiveWindowFocusReason, false); | - | ||||||||||||||||||||||||
| 528 | } never executed: else if (panel->flags() & QGraphicsItem::ItemIsFocusableend of block
| 0 | ||||||||||||||||||||||||
| 529 | setFocusItemHelper(panel, Qt::ActiveWindowFocusReason, false); | - | ||||||||||||||||||||||||
| 530 | } never executed: else if (panel->isWidget()end of block
| 0 | ||||||||||||||||||||||||
| 531 | QGraphicsWidget *fw = static_cast<QGraphicsWidget *>(panel)->d_func()->focusNext; | - | ||||||||||||||||||||||||
| 532 | do { | - | ||||||||||||||||||||||||
| 533 | if (fw->focusPolicy() & Qt::TabFocus
| 0 | ||||||||||||||||||||||||
| 534 | setFocusItemHelper(fw, Qt::ActiveWindowFocusReason, false); | - | ||||||||||||||||||||||||
| 535 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 536 | } | - | ||||||||||||||||||||||||
| 537 | fw = fw->d_func()->focusNext; | - | ||||||||||||||||||||||||
| 538 | } never executed: while (fw != panelend of block
| 0 | ||||||||||||||||||||||||
| 539 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 540 | } never executed: else if (q->isActive()end of block
| 0 | ||||||||||||||||||||||||
| 541 | const auto items = q->items(); | - | ||||||||||||||||||||||||
| 542 | - | |||||||||||||||||||||||||
| 543 | QEvent event(QEvent::WindowActivate); | - | ||||||||||||||||||||||||
| 544 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(q->items())>::type> _container_((q->items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) { | - | ||||||||||||||||||||||||
| 545 | if (item->isVisible()
| 0 | ||||||||||||||||||||||||
| 546 | q->sendEvent(item, &event); never executed: q->sendEvent(item, &event); | 0 | ||||||||||||||||||||||||
| 547 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 548 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | q->focusItemChanged(focusItem, oldFocusItem, Qt::ActiveWindowFocusReason); | - | ||||||||||||||||||||||||
| 551 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 552 | void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, | - | ||||||||||||||||||||||||
| 553 | Qt::FocusReason focusReason, | - | ||||||||||||||||||||||||
| 554 | bool emitFocusChanged) | - | ||||||||||||||||||||||||
| 555 | { | - | ||||||||||||||||||||||||
| 556 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 557 | if (item == focusItem) | - | ||||||||||||||||||||||||
| 558 | return; | - | ||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable) | - | ||||||||||||||||||||||||
| 563 | || !item->isVisible() || !item->isEnabled())) { | - | ||||||||||||||||||||||||
| 564 | item = 0; | - | ||||||||||||||||||||||||
| 565 | } | - | ||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||
| 567 | - | |||||||||||||||||||||||||
| 568 | if (item) { | - | ||||||||||||||||||||||||
| 569 | q->setFocus(focusReason); | - | ||||||||||||||||||||||||
| 570 | if (item == focusItem) { | - | ||||||||||||||||||||||||
| 571 | if (emitFocusChanged) | - | ||||||||||||||||||||||||
| 572 | q->focusItemChanged(focusItem, (QGraphicsItem *)0, focusReason); | - | ||||||||||||||||||||||||
| 573 | return; | - | ||||||||||||||||||||||||
| 574 | } | - | ||||||||||||||||||||||||
| 575 | } | - | ||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | QGraphicsItem *oldFocusItem = focusItem; | - | ||||||||||||||||||||||||
| 578 | if (focusItem) { | - | ||||||||||||||||||||||||
| 579 | lastFocusItem = focusItem; | - | ||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||
| 582 | if (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod) { | - | ||||||||||||||||||||||||
| 583 | - | |||||||||||||||||||||||||
| 584 | - | |||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | if ((static_cast<QApplication *>(QCoreApplication::instance()))) | - | ||||||||||||||||||||||||
| 588 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||
| 589 | } | - | ||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||
| 592 | focusItem = 0; | - | ||||||||||||||||||||||||
| 593 | QFocusEvent event(QEvent::FocusOut, focusReason); | - | ||||||||||||||||||||||||
| 594 | sendEvent(lastFocusItem, &event); | - | ||||||||||||||||||||||||
| 595 | } | - | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | - | |||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | if (item && item->scene() != q) | - | ||||||||||||||||||||||||
| 600 | item = 0; | - | ||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | if (item) | - | ||||||||||||||||||||||||
| 603 | focusItem = item; | - | ||||||||||||||||||||||||
| 604 | updateInputMethodSensitivityInViews(); | - | ||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||
| 606 | if (item) { | - | ||||||||||||||||||||||||
| 607 | QFocusEvent event(QEvent::FocusIn, focusReason); | - | ||||||||||||||||||||||||
| 608 | sendEvent(item, &event); | - | ||||||||||||||||||||||||
| 609 | } | - | ||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||
| 611 | if (emitFocusChanged) | - | ||||||||||||||||||||||||
| 612 | q->focusItemChanged(focusItem, oldFocusItem, focusReason); | - | ||||||||||||||||||||||||
| 613 | } | - | ||||||||||||||||||||||||
| 614 | - | |||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||
| 618 | void QGraphicsScenePrivate::addPopup(QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
| 619 | { | - | ||||||||||||||||||||||||
| 620 | ((!(widget)) ? qt_assert("widget",__FILE__,883892) : qt_noop()); | - | ||||||||||||||||||||||||
| 621 | ((!(!popupWidgets.contains(widget))) ? qt_assert("!popupWidgets.contains(widget)",__FILE__,884893) : qt_noop()); | - | ||||||||||||||||||||||||
| 622 | popupWidgets << widget; | - | ||||||||||||||||||||||||
| 623 | if (QGraphicsWidget *focusWidget = widget->focusWidget()) { | - | ||||||||||||||||||||||||
| 624 | focusWidget->setFocus(Qt::PopupFocusReason); | - | ||||||||||||||||||||||||
| 625 | } else { | - | ||||||||||||||||||||||||
| 626 | grabKeyboard((QGraphicsItem *)widget); | - | ||||||||||||||||||||||||
| 627 | if (focusItem && popupWidgets.size() == 1) { | - | ||||||||||||||||||||||||
| 628 | QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason); | - | ||||||||||||||||||||||||
| 629 | sendEvent(focusItem, &event); | - | ||||||||||||||||||||||||
| 630 | } | - | ||||||||||||||||||||||||
| 631 | } | - | ||||||||||||||||||||||||
| 632 | grabMouse((QGraphicsItem *)widget); | - | ||||||||||||||||||||||||
| 633 | } | - | ||||||||||||||||||||||||
| 634 | void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDying) | - | ||||||||||||||||||||||||
| 635 | { | - | ||||||||||||||||||||||||
| 636 | ((!(widget)) ? qt_assert("widget",__FILE__,909918) : qt_noop()); | - | ||||||||||||||||||||||||
| 637 | int index = popupWidgets.indexOf(widget); | - | ||||||||||||||||||||||||
| 638 | ((!(index != -1)) ? qt_assert("index != -1",__FILE__,911920) : qt_noop()); | - | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | for (int i = popupWidgets.size() - 1; i >= index; --i) { | - | ||||||||||||||||||||||||
| 641 | QGraphicsWidget *widget = popupWidgets.takeLast(); | - | ||||||||||||||||||||||||
| 642 | ungrabMouse(widget, itemIsDying); | - | ||||||||||||||||||||||||
| 643 | if (focusItem && popupWidgets.isEmpty()) { | - | ||||||||||||||||||||||||
| 644 | QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason); | - | ||||||||||||||||||||||||
| 645 | sendEvent(focusItem, &event); | - | ||||||||||||||||||||||||
| 646 | } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) { | - | ||||||||||||||||||||||||
| 647 | ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying); | - | ||||||||||||||||||||||||
| 648 | } | - | ||||||||||||||||||||||||
| 649 | if (!itemIsDying && widget->isVisible()) { | - | ||||||||||||||||||||||||
| 650 | widget->QGraphicsItem::d_ptr->setVisibleHelper(false, false); | - | ||||||||||||||||||||||||
| 651 | } | - | ||||||||||||||||||||||||
| 652 | } | - | ||||||||||||||||||||||||
| 653 | } | - | ||||||||||||||||||||||||
| 654 | - | |||||||||||||||||||||||||
| 655 | - | |||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||
| 657 | - | |||||||||||||||||||||||||
| 658 | void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit) | - | ||||||||||||||||||||||||
| 659 | { | - | ||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||
| 661 | if (mouseGrabberItems.contains(item)
| 0 | ||||||||||||||||||||||||
| 662 | if (mouseGrabberItems.lastconstLast() == item
| 0 | ||||||||||||||||||||||||
| 663 | ((!(!implicit)) ? qt_assert("!implicit",__FILE__,936945) : qt_noop()); | - | ||||||||||||||||||||||||
| 664 | if (!lastMouseGrabberItemHasImplicitMouseGrab
| 0 | ||||||||||||||||||||||||
| 665 | QMessageLogger(__FILE__, 938947, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: already a mouse grabber"); | - | ||||||||||||||||||||||||
| 666 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||
| 668 | lastMouseGrabberItemHasImplicitMouseGrab = false; | - | ||||||||||||||||||||||||
| 669 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 670 | } else { | - | ||||||||||||||||||||||||
| 671 | QMessageLogger(__FILE__, 944953, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p", | - | ||||||||||||||||||||||||
| 672 | mouseGrabberItems.lastconstLast()); | - | ||||||||||||||||||||||||
| 673 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 674 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 675 | } | - | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||
| 678 | if (!mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 679 | QGraphicsItem *last = mouseGrabberItems.lastconstLast(); | - | ||||||||||||||||||||||||
| 680 | if (lastMouseGrabberItemHasImplicitMouseGrab
| 0 | ||||||||||||||||||||||||
| 681 | - | |||||||||||||||||||||||||
| 682 | last->ungrabMouse(); | - | ||||||||||||||||||||||||
| 683 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 684 | - | |||||||||||||||||||||||||
| 685 | QEvent ungrabEvent(QEvent::UngrabMouse); | - | ||||||||||||||||||||||||
| 686 | sendEvent(last, &ungrabEvent); | - | ||||||||||||||||||||||||
| 687 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 688 | } | - | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | mouseGrabberItems << item; | - | ||||||||||||||||||||||||
| 691 | lastMouseGrabberItemHasImplicitMouseGrab = implicit; | - | ||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||
| 694 | QEvent grabEvent(QEvent::GrabMouse); | - | ||||||||||||||||||||||||
| 695 | sendEvent(item, &grabEvent); | - | ||||||||||||||||||||||||
| 696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying) | - | ||||||||||||||||||||||||
| 702 | { | - | ||||||||||||||||||||||||
| 703 | int index = mouseGrabberItems.indexOf(item); | - | ||||||||||||||||||||||||
| 704 | if (index == -1
| 0 | ||||||||||||||||||||||||
| 705 | QMessageLogger(__FILE__, 978987, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabMouse: not a mouse grabber"); | - | ||||||||||||||||||||||||
| 706 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 707 | } | - | ||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | if (item != mouseGrabberItems.lastconstLast()
| 0 | ||||||||||||||||||||||||
| 710 | - | |||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||
| 712 | ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying); | - | ||||||||||||||||||||||||
| 713 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 714 | if (!popupWidgets.isEmpty()
| 0 | ||||||||||||||||||||||||
| 715 | - | |||||||||||||||||||||||||
| 716 | - | |||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | removePopup(popupWidgets.constLast(), itemIsDying); | - | ||||||||||||||||||||||||
| 719 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 720 | } | - | ||||||||||||||||||||||||
| 721 | - | |||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||
| 723 | if (!itemIsDying
| 0 | ||||||||||||||||||||||||
| 724 | QEvent event(QEvent::UngrabMouse); | - | ||||||||||||||||||||||||
| 725 | sendEvent(item, &event); | - | ||||||||||||||||||||||||
| 726 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||
| 732 | mouseGrabberItems.takeLast(); | - | ||||||||||||||||||||||||
| 733 | lastMouseGrabberItemHasImplicitMouseGrab = false; | - | ||||||||||||||||||||||||
| 734 | - | |||||||||||||||||||||||||
| 735 | - | |||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||
| 738 | if (!itemIsDying
| 0 | ||||||||||||||||||||||||
| 739 | QGraphicsItem *last = mouseGrabberItems.lastconstLast(); | - | ||||||||||||||||||||||||
| 740 | QEvent event(QEvent::GrabMouse); | - | ||||||||||||||||||||||||
| 741 | sendEvent(last, &event); | - | ||||||||||||||||||||||||
| 742 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 743 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | - | |||||||||||||||||||||||||
| 748 | void QGraphicsScenePrivate::clearMouseGrabber() | - | ||||||||||||||||||||||||
| 749 | { | - | ||||||||||||||||||||||||
| 750 | if (!mouseGrabberItems.isEmpty()) | - | ||||||||||||||||||||||||
| 751 | mouseGrabberItems.first()->ungrabMouse(); | - | ||||||||||||||||||||||||
| 752 | lastMouseGrabberItem = 0; | - | ||||||||||||||||||||||||
| 753 | } | - | ||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||
| 758 | void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 759 | { | - | ||||||||||||||||||||||||
| 760 | if (keyboardGrabberItems.contains(item)
| 0 | ||||||||||||||||||||||||
| 761 | if (keyboardGrabberItems.lastconstLast() == item
| 0 | ||||||||||||||||||||||||
| 762 | QMessageLogger(__FILE__, 10351044, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already a keyboard grabber"); never executed: QMessageLogger(__FILE__, 1044, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already a keyboard grabber"); | 0 | ||||||||||||||||||||||||
| 763 | else | - | ||||||||||||||||||||||||
| 764 | QMessageLogger(__FILE__, 10371046, __PRETTY_FUNCTION__).warning("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 | ||||||||||||||||||||||||
| 765 | keyboardGrabberItems.lastconstLast()); never executed: QMessageLogger(__FILE__, 1046, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p", keyboardGrabberItems.constLast()); | 0 | ||||||||||||||||||||||||
| 766 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 767 | } | - | ||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||
| 770 | if (!keyboardGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||
| 772 | QEvent ungrabEvent(QEvent::UngrabKeyboard); | - | ||||||||||||||||||||||||
| 773 | sendEvent(keyboardGrabberItems.lastconstLast(), &ungrabEvent); | - | ||||||||||||||||||||||||
| 774 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 775 | - | |||||||||||||||||||||||||
| 776 | keyboardGrabberItems << item; | - | ||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||
| 779 | QEvent grabEvent(QEvent::GrabKeyboard); | - | ||||||||||||||||||||||||
| 780 | sendEvent(item, &grabEvent); | - | ||||||||||||||||||||||||
| 781 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||
| 785 | - | |||||||||||||||||||||||||
| 786 | void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying) | - | ||||||||||||||||||||||||
| 787 | { | - | ||||||||||||||||||||||||
| 788 | int index = keyboardGrabberItems.lastIndexOf(item); | - | ||||||||||||||||||||||||
| 789 | if (index == -1
| 0 | ||||||||||||||||||||||||
| 790 | QMessageLogger(__FILE__, 10631072, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber"); | - | ||||||||||||||||||||||||
| 791 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 792 | } | - | ||||||||||||||||||||||||
| 793 | if (item != keyboardGrabberItems.lastconstLast()
| 0 | ||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||
| 796 | ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying); | - | ||||||||||||||||||||||||
| 797 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 798 | - | |||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | if (!itemIsDying
| 0 | ||||||||||||||||||||||||
| 801 | QEvent event(QEvent::UngrabKeyboard); | - | ||||||||||||||||||||||||
| 802 | sendEvent(item, &event); | - | ||||||||||||||||||||||||
| 803 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 804 | - | |||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | keyboardGrabberItems.takeLast(); | - | ||||||||||||||||||||||||
| 807 | - | |||||||||||||||||||||||||
| 808 | - | |||||||||||||||||||||||||
| 809 | if (!itemIsDying
| 0 | ||||||||||||||||||||||||
| 810 | QGraphicsItem *last = keyboardGrabberItems.lastconstLast(); | - | ||||||||||||||||||||||||
| 811 | QEvent event(QEvent::GrabKeyboard); | - | ||||||||||||||||||||||||
| 812 | sendEvent(last, &event); | - | ||||||||||||||||||||||||
| 813 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 814 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||
| 816 | - | |||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | void QGraphicsScenePrivate::clearKeyboardGrabber() | - | ||||||||||||||||||||||||
| 820 | { | - | ||||||||||||||||||||||||
| 821 | if (!keyboardGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 822 | ungrabKeyboard(keyboardGrabberItems.firstconstFirst()); never executed: ungrabKeyboard(keyboardGrabberItems.constFirst()); | 0 | ||||||||||||||||||||||||
| 823 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | void QGraphicsScenePrivate::enableMouseTrackingOnViews() | - | ||||||||||||||||||||||||
| 826 | { | - | ||||||||||||||||||||||||
| 827 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(views)>::type> _container_((views)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsView *view = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
| 828 | view->viewport()->setMouseTracking(true); | - | ||||||||||||||||||||||||
| 829 | } | - | ||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||
| 833 | - | |||||||||||||||||||||||||
| 834 | QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &screenPos, | - | ||||||||||||||||||||||||
| 835 | const QPointF &scenePos, | - | ||||||||||||||||||||||||
| 836 | QWidget *widget) const | - | ||||||||||||||||||||||||
| 837 | { | - | ||||||||||||||||||||||||
| 838 | const QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 839 | QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0; | - | ||||||||||||||||||||||||
| 840 | if (!view) | - | ||||||||||||||||||||||||
| 841 | return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform()); | - | ||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||
| 843 | const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1)); | - | ||||||||||||||||||||||||
| 844 | if (!view->isTransformed()) | - | ||||||||||||||||||||||||
| 845 | return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder); | - | ||||||||||||||||||||||||
| 846 | - | |||||||||||||||||||||||||
| 847 | const QTransform viewTransform = view->viewportTransform(); | - | ||||||||||||||||||||||||
| 848 | if (viewTransform.type() <= QTransform::TxScale) { | - | ||||||||||||||||||||||||
| 849 | return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, | - | ||||||||||||||||||||||||
| 850 | Qt::DescendingOrder, viewTransform); | - | ||||||||||||||||||||||||
| 851 | } | - | ||||||||||||||||||||||||
| 852 | return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, | - | ||||||||||||||||||||||||
| 853 | Qt::DescendingOrder, viewTransform); | - | ||||||||||||||||||||||||
| 854 | } | - | ||||||||||||||||||||||||
| 855 | - | |||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | void QGraphicsScenePrivate::storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event) | - | ||||||||||||||||||||||||
| 860 | { | - | ||||||||||||||||||||||||
| 861 | for (int i = 0x1; i <= 0x10
| 0 | ||||||||||||||||||||||||
| 862 | if (event->buttons() & i
| 0 | ||||||||||||||||||||||||
| 863 | mouseGrabberButtonDownPos.insert(Qt::MouseButton(i), | - | ||||||||||||||||||||||||
| 864 | mouseGrabberItems.lastconstLast()->d_ptr->genericMapFromScene(event->scenePos(), | - | ||||||||||||||||||||||||
| 865 | event->widget())); | - | ||||||||||||||||||||||||
| 866 | mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos()); | - | ||||||||||||||||||||||||
| 867 | mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos()); | - | ||||||||||||||||||||||||
| 868 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 869 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 870 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||
| 875 | void QGraphicsScenePrivate::installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter) | - | ||||||||||||||||||||||||
| 876 | { | - | ||||||||||||||||||||||||
| 877 | sceneEventFilters.insert(watched, filter); | - | ||||||||||||||||||||||||
| 878 | } | - | ||||||||||||||||||||||||
| 879 | - | |||||||||||||||||||||||||
| 880 | - | |||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||
| 883 | void QGraphicsScenePrivate::removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter) | - | ||||||||||||||||||||||||
| 884 | { | - | ||||||||||||||||||||||||
| 885 | if (!sceneEventFilters.contains(watched)) | - | ||||||||||||||||||||||||
| 886 | return; | - | ||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(watched); | - | ||||||||||||||||||||||||
| 889 | QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(watched); | - | ||||||||||||||||||||||||
| 890 | do { | - | ||||||||||||||||||||||||
| 891 | if (it.value() == filter) | - | ||||||||||||||||||||||||
| 892 | it = sceneEventFilters.erase(it); | - | ||||||||||||||||||||||||
| 893 | else | - | ||||||||||||||||||||||||
| 894 | ++it; | - | ||||||||||||||||||||||||
| 895 | } while (it != end); | - | ||||||||||||||||||||||||
| 896 | } | - | ||||||||||||||||||||||||
| 897 | - | |||||||||||||||||||||||||
| 898 | - | |||||||||||||||||||||||||
| 899 | - | |||||||||||||||||||||||||
| 900 | - | |||||||||||||||||||||||||
| 901 | bool QGraphicsScenePrivate::filterDescendantEvent(QGraphicsItem *item, QEvent *event) | - | ||||||||||||||||||||||||
| 902 | { | - | ||||||||||||||||||||||||
| 903 | if (item && (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) { | - | ||||||||||||||||||||||||
| 904 | QGraphicsItem *parent = item->parentItem(); | - | ||||||||||||||||||||||||
| 905 | while (parent) { | - | ||||||||||||||||||||||||
| 906 | if (parent->d_ptr->filtersDescendantEvents && parent->sceneEventFilter(item, event)) | - | ||||||||||||||||||||||||
| 907 | return true; | - | ||||||||||||||||||||||||
| 908 | if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) | - | ||||||||||||||||||||||||
| 909 | return false; | - | ||||||||||||||||||||||||
| 910 | parent = parent->parentItem(); | - | ||||||||||||||||||||||||
| 911 | } | - | ||||||||||||||||||||||||
| 912 | } | - | ||||||||||||||||||||||||
| 913 | return false; | - | ||||||||||||||||||||||||
| 914 | } | - | ||||||||||||||||||||||||
| 915 | - | |||||||||||||||||||||||||
| 916 | - | |||||||||||||||||||||||||
| 917 | - | |||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event) | - | ||||||||||||||||||||||||
| 920 | { | - | ||||||||||||||||||||||||
| 921 | if (item && !sceneEventFilters.contains(item)) | - | ||||||||||||||||||||||||
| 922 | return false; | - | ||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||
| 924 | QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(item); | - | ||||||||||||||||||||||||
| 925 | QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(item); | - | ||||||||||||||||||||||||
| 926 | while (it != end) { | - | ||||||||||||||||||||||||
| 927 | - | |||||||||||||||||||||||||
| 928 | if (it.value()->sceneEventFilter(it.key(), event)) | - | ||||||||||||||||||||||||
| 929 | return true; | - | ||||||||||||||||||||||||
| 930 | ++it; | - | ||||||||||||||||||||||||
| 931 | } | - | ||||||||||||||||||||||||
| 932 | return false; | - | ||||||||||||||||||||||||
| 933 | } | - | ||||||||||||||||||||||||
| 934 | bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) | - | ||||||||||||||||||||||||
| 935 | { | - | ||||||||||||||||||||||||
| 936 | if (QGraphicsObject *object = item->toGraphicsObject()) { | - | ||||||||||||||||||||||||
| 937 | - | |||||||||||||||||||||||||
| 938 | QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager; | - | ||||||||||||||||||||||||
| 939 | if (gestureManager) { | - | ||||||||||||||||||||||||
| 940 | if (gestureManager->filterEvent(object, event)) | - | ||||||||||||||||||||||||
| 941 | return true; | - | ||||||||||||||||||||||||
| 942 | } | - | ||||||||||||||||||||||||
| 943 | - | |||||||||||||||||||||||||
| 944 | } | - | ||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||
| 946 | if (filterEvent(item, event)) | - | ||||||||||||||||||||||||
| 947 | return false; | - | ||||||||||||||||||||||||
| 948 | if (filterDescendantEvent(item, event)) | - | ||||||||||||||||||||||||
| 949 | return false; | - | ||||||||||||||||||||||||
| 950 | if (!item || !item->isEnabled()) | - | ||||||||||||||||||||||||
| 951 | return false; | - | ||||||||||||||||||||||||
| 952 | if (QGraphicsObject *o = item->toGraphicsObject()) { | - | ||||||||||||||||||||||||
| 953 | bool spont = event->spontaneous(); | - | ||||||||||||||||||||||||
| 954 | if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event)) | - | ||||||||||||||||||||||||
| 955 | return true; | - | ||||||||||||||||||||||||
| 956 | event->spont = spont; | - | ||||||||||||||||||||||||
| 957 | } | - | ||||||||||||||||||||||||
| 958 | return item->sceneEvent(event); | - | ||||||||||||||||||||||||
| 959 | } | - | ||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||
| 961 | - | |||||||||||||||||||||||||
| 962 | - | |||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | void QGraphicsScenePrivate::cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest, | - | ||||||||||||||||||||||||
| 965 | QGraphicsSceneDragDropEvent *source) | - | ||||||||||||||||||||||||
| 966 | { | - | ||||||||||||||||||||||||
| 967 | dest->setWidget(source->widget()); | - | ||||||||||||||||||||||||
| 968 | dest->setPos(source->pos()); | - | ||||||||||||||||||||||||
| 969 | dest->setScenePos(source->scenePos()); | - | ||||||||||||||||||||||||
| 970 | dest->setScreenPos(source->screenPos()); | - | ||||||||||||||||||||||||
| 971 | dest->setButtons(source->buttons()); | - | ||||||||||||||||||||||||
| 972 | dest->setModifiers(source->modifiers()); | - | ||||||||||||||||||||||||
| 973 | dest->setPossibleActions(source->possibleActions()); | - | ||||||||||||||||||||||||
| 974 | dest->setProposedAction(source->proposedAction()); | - | ||||||||||||||||||||||||
| 975 | dest->setDropAction(source->dropAction()); | - | ||||||||||||||||||||||||
| 976 | dest->setSource(source->source()); | - | ||||||||||||||||||||||||
| 977 | dest->setMimeData(source->mimeData()); | - | ||||||||||||||||||||||||
| 978 | } | - | ||||||||||||||||||||||||
| 979 | - | |||||||||||||||||||||||||
| 980 | - | |||||||||||||||||||||||||
| 981 | - | |||||||||||||||||||||||||
| 982 | - | |||||||||||||||||||||||||
| 983 | void QGraphicsScenePrivate::sendDragDropEvent(QGraphicsItem *item, | - | ||||||||||||||||||||||||
| 984 | QGraphicsSceneDragDropEvent *dragDropEvent) | - | ||||||||||||||||||||||||
| 985 | { | - | ||||||||||||||||||||||||
| 986 | dragDropEvent->setPos(item->d_ptr->genericMapFromScene(dragDropEvent->scenePos(), dragDropEvent->widget())); | - | ||||||||||||||||||||||||
| 987 | sendEvent(item, dragDropEvent); | - | ||||||||||||||||||||||||
| 988 | } | - | ||||||||||||||||||||||||
| 989 | - | |||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||
| 991 | - | |||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||
| 993 | void QGraphicsScenePrivate::sendHoverEvent(QEvent::Type type, QGraphicsItem *item, | - | ||||||||||||||||||||||||
| 994 | QGraphicsSceneHoverEvent *hoverEvent) | - | ||||||||||||||||||||||||
| 995 | { | - | ||||||||||||||||||||||||
| 996 | QGraphicsSceneHoverEvent event(type); | - | ||||||||||||||||||||||||
| 997 | event.setWidget(hoverEvent->widget()); | - | ||||||||||||||||||||||||
| 998 | event.setPos(item->d_ptr->genericMapFromScene(hoverEvent->scenePos(), hoverEvent->widget())); | - | ||||||||||||||||||||||||
| 999 | event.setScenePos(hoverEvent->scenePos()); | - | ||||||||||||||||||||||||
| 1000 | event.setScreenPos(hoverEvent->screenPos()); | - | ||||||||||||||||||||||||
| 1001 | event.setLastPos(item->d_ptr->genericMapFromScene(hoverEvent->lastScenePos(), hoverEvent->widget())); | - | ||||||||||||||||||||||||
| 1002 | event.setLastScenePos(hoverEvent->lastScenePos()); | - | ||||||||||||||||||||||||
| 1003 | event.setLastScreenPos(hoverEvent->lastScreenPos()); | - | ||||||||||||||||||||||||
| 1004 | event.setModifiers(hoverEvent->modifiers()); | - | ||||||||||||||||||||||||
| 1005 | sendEvent(item, &event); | - | ||||||||||||||||||||||||
| 1006 | } | - | ||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||
| 1008 | - | |||||||||||||||||||||||||
| 1009 | - | |||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||
| 1011 | void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 1012 | { | - | ||||||||||||||||||||||||
| 1013 | if (mouseEvent->button() == 0
| 0 | ||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||
| 1016 | clearMouseGrabber(); | - | ||||||||||||||||||||||||
| 1017 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1018 | } | - | ||||||||||||||||||||||||
| 1019 | - | |||||||||||||||||||||||||
| 1020 | QGraphicsItem *item = mouseGrabberItems.lastconstLast(); | - | ||||||||||||||||||||||||
| 1021 | if (item->isBlockedByModalPanel()
| 0 | ||||||||||||||||||||||||
| 1022 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1023 | - | |||||||||||||||||||||||||
| 1024 | for (int i = 0x1; i <= 0x10
| 0 | ||||||||||||||||||||||||
| 1025 | Qt::MouseButton button = Qt::MouseButton(i); | - | ||||||||||||||||||||||||
| 1026 | mouseEvent->setButtonDownPos(button, mouseGrabberButtonDownPos.value(button, item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget()))); | - | ||||||||||||||||||||||||
| 1027 | mouseEvent->setButtonDownScenePos(button, mouseGrabberButtonDownScenePos.value(button, mouseEvent->scenePos())); | - | ||||||||||||||||||||||||
| 1028 | mouseEvent->setButtonDownScreenPos(button, mouseGrabberButtonDownScreenPos.value(button, mouseEvent->screenPos())); | - | ||||||||||||||||||||||||
| 1029 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1030 | mouseEvent->setPos(item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget())); | - | ||||||||||||||||||||||||
| 1031 | mouseEvent->setLastPos(item->d_ptr->genericMapFromScene(mouseEvent->lastScenePos(), mouseEvent->widget())); | - | ||||||||||||||||||||||||
| 1032 | sendEvent(item, mouseEvent); | - | ||||||||||||||||||||||||
| 1033 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||
| 1038 | void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 1039 | { | - | ||||||||||||||||||||||||
| 1040 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||
| 1042 | - | |||||||||||||||||||||||||
| 1043 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 1044 | - | |||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||
| 1046 | if (!mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1047 | if (mouseGrabberItems.lastconstLast()->isBlockedByModalPanel()
| 0 | ||||||||||||||||||||||||
| 1048 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||
| 1051 | sendMouseEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 1052 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1053 | } | - | ||||||||||||||||||||||||
| 1054 | - | |||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||
| 1057 | if (cachedItemsUnderMouse.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1058 | cachedItemsUnderMouse = itemsAtPosition(mouseEvent->screenPos(), | - | ||||||||||||||||||||||||
| 1059 | mouseEvent->scenePos(), | - | ||||||||||||||||||||||||
| 1060 | mouseEvent->widget()); | - | ||||||||||||||||||||||||
| 1061 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||
| 1063 | - | |||||||||||||||||||||||||
| 1064 | QGraphicsItem *topItem = cachedItemsUnderMouse.value(0); | - | ||||||||||||||||||||||||
| 1065 | QGraphicsWidget *newActiveWindow = topItem
| 0 | ||||||||||||||||||||||||
| 1066 | if (newActiveWindow
| 0 | ||||||||||||||||||||||||
| 1067 | - | |||||||||||||||||||||||||
| 1068 | newActiveWindow = topItem
| 0 | ||||||||||||||||||||||||
| 1069 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1070 | - | |||||||||||||||||||||||||
| 1071 | if (newActiveWindow != q->activeWindow()
| 0 | ||||||||||||||||||||||||
| 1072 | q->setActiveWindow(newActiveWindow); never executed: q->setActiveWindow(newActiveWindow); | 0 | ||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | - | |||||||||||||||||||||||||
| 1075 | bool setFocus = false; | - | ||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||
| 1077 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(cachedItemsUnderMouse)>::type> _container_((cachedItemsUnderMouse)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 1078 | if (item->isBlockedByModalPanel()
| 0 | ||||||||||||||||||||||||
| 1079 | || (
| 0 | ||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | setFocus = true; | - | ||||||||||||||||||||||||
| 1082 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1083 | } | - | ||||||||||||||||||||||||
| 1084 | if (item->isEnabled()
| 0 | ||||||||||||||||||||||||
| 1085 | if (!item->isWidget()
| 0 | ||||||||||||||||||||||||
| 1086 | setFocus = true; | - | ||||||||||||||||||||||||
| 1087 | if (item != q->focusItem()
| 0 | ||||||||||||||||||||||||
| 1088 | q->setFocusItem(item, Qt::MouseFocusReason); never executed: q->setFocusItem(item, Qt::MouseFocusReason); | 0 | ||||||||||||||||||||||||
| 1089 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1090 | } | - | ||||||||||||||||||||||||
| 1091 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1092 | if (item->isPanel()
| 0 | ||||||||||||||||||||||||
| 1093 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1094 | if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation
| 0 | ||||||||||||||||||||||||
| 1095 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1096 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1097 | - | |||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||
| 1099 | bool sceneModality = false; | - | ||||||||||||||||||||||||
| 1100 | for (int i = 0; i < modalPanels.size()
| 0 | ||||||||||||||||||||||||
| 1101 | if (modalPanels.at(i)->panelModality() == QGraphicsItem::SceneModal
| 0 | ||||||||||||||||||||||||
| 1102 | sceneModality = true; | - | ||||||||||||||||||||||||
| 1103 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1104 | } | - | ||||||||||||||||||||||||
| 1105 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | if (!stickyFocus
| 0 | ||||||||||||||||||||||||
| 1109 | q->setFocusItem(0, Qt::MouseFocusReason); never executed: q->setFocusItem(0, Qt::MouseFocusReason); | 0 | ||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | - | |||||||||||||||||||||||||
| 1112 | if (sceneModality
| 0 | ||||||||||||||||||||||||
| 1113 | cachedItemsUnderMouse << modalPanels.firstconstFirst(); never executed: cachedItemsUnderMouse << modalPanels.constFirst(); | 0 | ||||||||||||||||||||||||
| 1114 | - | |||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||
| 1116 | - | |||||||||||||||||||||||||
| 1117 | - | |||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||
| 1119 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(cachedItemsUnderMouse)>::type> _container_((cachedItemsUnderMouse)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 1120 | if (!(item->acceptedMouseButtons() & mouseEvent->button())
| 0 | ||||||||||||||||||||||||
| 1121 | - | |||||||||||||||||||||||||
| 1122 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1123 | } | - | ||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||
| 1125 | - | |||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||
| 1127 | (void) item->isBlockedByModalPanel(&item); | - | ||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||
| 1129 | grabMouse(item, true); | - | ||||||||||||||||||||||||
| 1130 | mouseEvent->accept(); | - | ||||||||||||||||||||||||
| 1131 | - | |||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | bool disabled = !item->isEnabled(); | - | ||||||||||||||||||||||||
| 1134 | bool isPanel = item->isPanel(); | - | ||||||||||||||||||||||||
| 1135 | if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick
| 0 | ||||||||||||||||||||||||
| 1136 | && item != lastMouseGrabberItem
| 0 | ||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||
| 1139 | - | |||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress); | - | ||||||||||||||||||||||||
| 1142 | mousePress.spont = mouseEvent->spont; | - | ||||||||||||||||||||||||
| 1143 | mousePress.accept(); | - | ||||||||||||||||||||||||
| 1144 | mousePress.setButton(mouseEvent->button()); | - | ||||||||||||||||||||||||
| 1145 | mousePress.setButtons(mouseEvent->buttons()); | - | ||||||||||||||||||||||||
| 1146 | mousePress.setScreenPos(mouseEvent->screenPos()); | - | ||||||||||||||||||||||||
| 1147 | mousePress.setScenePos(mouseEvent->scenePos()); | - | ||||||||||||||||||||||||
| 1148 | mousePress.setModifiers(mouseEvent->modifiers()); | - | ||||||||||||||||||||||||
| 1149 | mousePress.setWidget(mouseEvent->widget()); | - | ||||||||||||||||||||||||
| 1150 | mousePress.setButtonDownPos(mouseEvent->button(), | - | ||||||||||||||||||||||||
| 1151 | mouseEvent->buttonDownPos(mouseEvent->button())); | - | ||||||||||||||||||||||||
| 1152 | mousePress.setButtonDownScenePos(mouseEvent->button(), | - | ||||||||||||||||||||||||
| 1153 | mouseEvent->buttonDownScenePos(mouseEvent->button())); | - | ||||||||||||||||||||||||
| 1154 | mousePress.setButtonDownScreenPos(mouseEvent->button(), | - | ||||||||||||||||||||||||
| 1155 | mouseEvent->buttonDownScreenPos(mouseEvent->button())); | - | ||||||||||||||||||||||||
| 1156 | sendMouseEvent(&mousePress); | - | ||||||||||||||||||||||||
| 1157 | mouseEvent->setAccepted(mousePress.isAccepted()); | - | ||||||||||||||||||||||||
| 1158 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1159 | sendMouseEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 1160 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1161 | - | |||||||||||||||||||||||||
| 1162 | bool dontSendUngrabEvents = mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1163 | if (disabled
| 0 | ||||||||||||||||||||||||
| 1164 | ungrabMouse(item, dontSendUngrabEvents); | - | ||||||||||||||||||||||||
| 1165 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1166 | } | - | ||||||||||||||||||||||||
| 1167 | if (mouseEvent->isAccepted()
| 0 | ||||||||||||||||||||||||
| 1168 | if (!mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1169 | storeMouseButtonsForMouseGrabber(mouseEvent); never executed: storeMouseButtonsForMouseGrabber(mouseEvent); | 0 | ||||||||||||||||||||||||
| 1170 | lastMouseGrabberItem = item; | - | ||||||||||||||||||||||||
| 1171 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1172 | } | - | ||||||||||||||||||||||||
| 1173 | ungrabMouse(item, dontSendUngrabEvents); | - | ||||||||||||||||||||||||
| 1174 | - | |||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | if (isPanel
| 0 | ||||||||||||||||||||||||
| 1177 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1178 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||
| 1180 | - | |||||||||||||||||||||||||
| 1181 | - | |||||||||||||||||||||||||
| 1182 | - | |||||||||||||||||||||||||
| 1183 | - | |||||||||||||||||||||||||
| 1184 | if (!mouseEvent->isAccepted()
| 0 | ||||||||||||||||||||||||
| 1185 | clearMouseGrabber(); | - | ||||||||||||||||||||||||
| 1186 | - | |||||||||||||||||||||||||
| 1187 | QGraphicsView *view = mouseEvent->widget()
| 0 | ||||||||||||||||||||||||
| 1188 | bool dontClearSelection = view
| 0 | ||||||||||||||||||||||||
| 1189 | bool extendSelection = (mouseEvent->modifiers() & Qt::ControlModifier) != 0; | - | ||||||||||||||||||||||||
| 1190 | dontClearSelection |= extendSelection; | - | ||||||||||||||||||||||||
| 1191 | if (!dontClearSelection
| 0 | ||||||||||||||||||||||||
| 1192 | - | |||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||
| 1194 | - | |||||||||||||||||||||||||
| 1195 | q->clearSelection(); | - | ||||||||||||||||||||||||
| 1196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1197 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1199 | void QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes() | - | ||||||||||||||||||||||||
| 1200 | { | - | ||||||||||||||||||||||||
| 1201 | if (!topLevelSequentialOrdering) { | - | ||||||||||||||||||||||||
| 1202 | std::sort(topLevelItems.begin(), topLevelItems.end(), QGraphicsItemPrivate::insertionOrder); | - | ||||||||||||||||||||||||
| 1203 | topLevelSequentialOrdering = true; | - | ||||||||||||||||||||||||
| 1204 | needSortTopLevelItems = 1; | - | ||||||||||||||||||||||||
| 1205 | } | - | ||||||||||||||||||||||||
| 1206 | if (holesInTopLevelSiblingIndex) { | - | ||||||||||||||||||||||||
| 1207 | holesInTopLevelSiblingIndex = 0; | - | ||||||||||||||||||||||||
| 1208 | for (int i = 0; i < topLevelItems.size(); ++i) | - | ||||||||||||||||||||||||
| 1209 | topLevelItems[i]->d_ptr->siblingIndex = i; | - | ||||||||||||||||||||||||
| 1210 | } | - | ||||||||||||||||||||||||
| 1211 | } | - | ||||||||||||||||||||||||
| 1212 | - | |||||||||||||||||||||||||
| 1213 | - | |||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||
| 1216 | - | |||||||||||||||||||||||||
| 1217 | - | |||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||
| 1219 | void QGraphicsScenePrivate::setFont_helper(const QFont &font) | - | ||||||||||||||||||||||||
| 1220 | { | - | ||||||||||||||||||||||||
| 1221 | if (this->font == font && this->font.resolve() == font.resolve()) | - | ||||||||||||||||||||||||
| 1222 | return; | - | ||||||||||||||||||||||||
| 1223 | updateFont(font); | - | ||||||||||||||||||||||||
| 1224 | } | - | ||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||
| 1226 | - | |||||||||||||||||||||||||
| 1227 | - | |||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||
| 1229 | - | |||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||
| 1232 | void QGraphicsScenePrivate::resolveFont() | - | ||||||||||||||||||||||||
| 1233 | { | - | ||||||||||||||||||||||||
| 1234 | QFont naturalFont = QApplication::font(); | - | ||||||||||||||||||||||||
| 1235 | naturalFont.resolve(0); | - | ||||||||||||||||||||||||
| 1236 | QFont resolvedFont = font.resolve(naturalFont); | - | ||||||||||||||||||||||||
| 1237 | updateFont(resolvedFont); | - | ||||||||||||||||||||||||
| 1238 | } | - | ||||||||||||||||||||||||
| 1239 | - | |||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||
| 1241 | - | |||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||
| 1243 | - | |||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||
| 1246 | void QGraphicsScenePrivate::updateFont(const QFont &font) | - | ||||||||||||||||||||||||
| 1247 | { | - | ||||||||||||||||||||||||
| 1248 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 1249 | - | |||||||||||||||||||||||||
| 1250 | - | |||||||||||||||||||||||||
| 1251 | this->font = font; | - | ||||||||||||||||||||||||
| 1252 | - | |||||||||||||||||||||||||
| 1253 | - | |||||||||||||||||||||||||
| 1254 | - | |||||||||||||||||||||||||
| 1255 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(q->const auto items ())>::type> _container_((= q->items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||||||||
| 1256 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) { | - | ||||||||||||||||||||||||
| 1257 | if (!item->parentItem()
| 0 | ||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | - | |||||||||||||||||||||||||
| 1260 | - | |||||||||||||||||||||||||
| 1261 | item->d_ptr->resolveFont(font.resolve()); | - | ||||||||||||||||||||||||
| 1262 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1263 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1264 | - | |||||||||||||||||||||||||
| 1265 | - | |||||||||||||||||||||||||
| 1266 | QEvent event(QEvent::FontChange); | - | ||||||||||||||||||||||||
| 1267 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||
| 1268 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1269 | - | |||||||||||||||||||||||||
| 1270 | - | |||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||
| 1272 | - | |||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||
| 1276 | void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette) | - | ||||||||||||||||||||||||
| 1277 | { | - | ||||||||||||||||||||||||
| 1278 | if (this->palette == palette && this->palette.resolve() == palette.resolve()) | - | ||||||||||||||||||||||||
| 1279 | return; | - | ||||||||||||||||||||||||
| 1280 | updatePalette(palette); | - | ||||||||||||||||||||||||
| 1281 | } | - | ||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||
| 1284 | - | |||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||
| 1286 | - | |||||||||||||||||||||||||
| 1287 | - | |||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||
| 1289 | void QGraphicsScenePrivate::resolvePalette() | - | ||||||||||||||||||||||||
| 1290 | { | - | ||||||||||||||||||||||||
| 1291 | QPalette naturalPalette = QApplication::palette(); | - | ||||||||||||||||||||||||
| 1292 | naturalPalette.resolve(0); | - | ||||||||||||||||||||||||
| 1293 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - | ||||||||||||||||||||||||
| 1294 | updatePalette(resolvedPalette); | - | ||||||||||||||||||||||||
| 1295 | } | - | ||||||||||||||||||||||||
| 1296 | - | |||||||||||||||||||||||||
| 1297 | - | |||||||||||||||||||||||||
| 1298 | - | |||||||||||||||||||||||||
| 1299 | - | |||||||||||||||||||||||||
| 1300 | - | |||||||||||||||||||||||||
| 1301 | - | |||||||||||||||||||||||||
| 1302 | - | |||||||||||||||||||||||||
| 1303 | void QGraphicsScenePrivate::updatePalette(const QPalette &palette) | - | ||||||||||||||||||||||||
| 1304 | { | - | ||||||||||||||||||||||||
| 1305 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 1306 | - | |||||||||||||||||||||||||
| 1307 | - | |||||||||||||||||||||||||
| 1308 | this->palette = palette; | - | ||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||
| 1311 | - | |||||||||||||||||||||||||
| 1312 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(q->const auto items ())>::type> _container_((= q->items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||||||||
| 1313 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) { | - | ||||||||||||||||||||||||
| 1314 | if (!item->parentItem()
| 0 | ||||||||||||||||||||||||
| 1315 | - | |||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||
| 1317 | - | |||||||||||||||||||||||||
| 1318 | item->d_ptr->resolvePalette(palette.resolve()); | - | ||||||||||||||||||||||||
| 1319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1321 | - | |||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||
| 1323 | QEvent event(QEvent::PaletteChange); | - | ||||||||||||||||||||||||
| 1324 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||
| 1325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1326 | - | |||||||||||||||||||||||||
| 1327 | - | |||||||||||||||||||||||||
| 1328 | - | |||||||||||||||||||||||||
| 1329 | - | |||||||||||||||||||||||||
| 1330 | - | |||||||||||||||||||||||||
| 1331 | QGraphicsScene::QGraphicsScene(QObject *parent) | - | ||||||||||||||||||||||||
| 1332 | : QObject(*new QGraphicsScenePrivate, parent) | - | ||||||||||||||||||||||||
| 1333 | { | - | ||||||||||||||||||||||||
| 1334 | d_func()->init(); | - | ||||||||||||||||||||||||
| 1335 | } | - | ||||||||||||||||||||||||
| 1336 | QGraphicsScene::QGraphicsScene(const QRectF &sceneRect, QObject *parent) | - | ||||||||||||||||||||||||
| 1337 | : QObject(*new QGraphicsScenePrivate, parent) | - | ||||||||||||||||||||||||
| 1338 | { | - | ||||||||||||||||||||||||
| 1339 | d_func()->init(); | - | ||||||||||||||||||||||||
| 1340 | setSceneRect(sceneRect); | - | ||||||||||||||||||||||||
| 1341 | } | - | ||||||||||||||||||||||||
| 1342 | QGraphicsScene::QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent) | - | ||||||||||||||||||||||||
| 1343 | : QObject(*new QGraphicsScenePrivate, parent) | - | ||||||||||||||||||||||||
| 1344 | { | - | ||||||||||||||||||||||||
| 1345 | d_func()->init(); | - | ||||||||||||||||||||||||
| 1346 | setSceneRect(x, y, width, height); | - | ||||||||||||||||||||||||
| 1347 | } | - | ||||||||||||||||||||||||
| 1348 | - | |||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||
| 1350 | - | |||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||
| 1353 | - | |||||||||||||||||||||||||
| 1354 | - | |||||||||||||||||||||||||
| 1355 | QGraphicsScene::~QGraphicsScene() | - | ||||||||||||||||||||||||
| 1356 | { | - | ||||||||||||||||||||||||
| 1357 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1358 | - | |||||||||||||||||||||||||
| 1359 | - | |||||||||||||||||||||||||
| 1360 | if (!QApplicationPrivate::is_app_closing) | - | ||||||||||||||||||||||||
| 1361 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->scene_list.removeAll(this); | - | ||||||||||||||||||||||||
| 1362 | - | |||||||||||||||||||||||||
| 1363 | clear(); | - | ||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||
| 1366 | for (int j = 0; j < d->views.size(); ++j) | - | ||||||||||||||||||||||||
| 1367 | d->views.at(j)->setScene(0); | - | ||||||||||||||||||||||||
| 1368 | } | - | ||||||||||||||||||||||||
| 1369 | QRectF QGraphicsScene::sceneRect() const | - | ||||||||||||||||||||||||
| 1370 | { | - | ||||||||||||||||||||||||
| 1371 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1372 | if (d->hasSceneRect) | - | ||||||||||||||||||||||||
| 1373 | return d->sceneRect; | - | ||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||
| 1375 | if (d->dirtyGrowingItemsBoundingRect) { | - | ||||||||||||||||||||||||
| 1376 | - | |||||||||||||||||||||||||
| 1377 | QGraphicsScenePrivate *thatd = const_cast<QGraphicsScenePrivate *>(d); | - | ||||||||||||||||||||||||
| 1378 | QRectF oldGrowingBoundingRect = thatd->growingItemsBoundingRect; | - | ||||||||||||||||||||||||
| 1379 | thatd->growingItemsBoundingRect |= itemsBoundingRect(); | - | ||||||||||||||||||||||||
| 1380 | thatd->dirtyGrowingItemsBoundingRect = false; | - | ||||||||||||||||||||||||
| 1381 | if (oldGrowingBoundingRect != thatd->growingItemsBoundingRect) | - | ||||||||||||||||||||||||
| 1382 | const_cast<QGraphicsScene *>(this)->sceneRectChanged(thatd->growingItemsBoundingRect); | - | ||||||||||||||||||||||||
| 1383 | } | - | ||||||||||||||||||||||||
| 1384 | return d->growingItemsBoundingRect; | - | ||||||||||||||||||||||||
| 1385 | } | - | ||||||||||||||||||||||||
| 1386 | void QGraphicsScene::setSceneRect(const QRectF &rect) | - | ||||||||||||||||||||||||
| 1387 | { | - | ||||||||||||||||||||||||
| 1388 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1389 | if (rect != d->sceneRect) { | - | ||||||||||||||||||||||||
| 1390 | d->hasSceneRect = !rect.isNull(); | - | ||||||||||||||||||||||||
| 1391 | d->sceneRect = rect; | - | ||||||||||||||||||||||||
| 1392 | sceneRectChanged(d->hasSceneRect ? rect : d->growingItemsBoundingRect); | - | ||||||||||||||||||||||||
| 1393 | } | - | ||||||||||||||||||||||||
| 1394 | } | - | ||||||||||||||||||||||||
| 1395 | void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRectF &source, | - | ||||||||||||||||||||||||
| 1396 | Qt::AspectRatioMode aspectRatioMode) | - | ||||||||||||||||||||||||
| 1397 | { | - | ||||||||||||||||||||||||
| 1398 | - | |||||||||||||||||||||||||
| 1399 | - | |||||||||||||||||||||||||
| 1400 | - | |||||||||||||||||||||||||
| 1401 | QRectF sourceRect = source; | - | ||||||||||||||||||||||||
| 1402 | if (sourceRect.isNull()) | - | ||||||||||||||||||||||||
| 1403 | sourceRect = sceneRect(); | - | ||||||||||||||||||||||||
| 1404 | - | |||||||||||||||||||||||||
| 1405 | - | |||||||||||||||||||||||||
| 1406 | QRectF targetRect = target; | - | ||||||||||||||||||||||||
| 1407 | if (targetRect.isNull()) { | - | ||||||||||||||||||||||||
| 1408 | if (painter->device()->devType() == QInternal::Picture) | - | ||||||||||||||||||||||||
| 1409 | targetRect = sourceRect; | - | ||||||||||||||||||||||||
| 1410 | else | - | ||||||||||||||||||||||||
| 1411 | targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height()); | - | ||||||||||||||||||||||||
| 1412 | } | - | ||||||||||||||||||||||||
| 1413 | - | |||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||
| 1415 | qreal xratio = targetRect.width() / sourceRect.width(); | - | ||||||||||||||||||||||||
| 1416 | qreal yratio = targetRect.height() / sourceRect.height(); | - | ||||||||||||||||||||||||
| 1417 | - | |||||||||||||||||||||||||
| 1418 | - | |||||||||||||||||||||||||
| 1419 | switch (aspectRatioMode) { | - | ||||||||||||||||||||||||
| 1420 | case Qt::KeepAspectRatio: | - | ||||||||||||||||||||||||
| 1421 | xratio = yratio = qMin(xratio, yratio); | - | ||||||||||||||||||||||||
| 1422 | break; | - | ||||||||||||||||||||||||
| 1423 | case Qt::KeepAspectRatioByExpanding: | - | ||||||||||||||||||||||||
| 1424 | xratio = yratio = qMax(xratio, yratio); | - | ||||||||||||||||||||||||
| 1425 | break; | - | ||||||||||||||||||||||||
| 1426 | case Qt::IgnoreAspectRatio: | - | ||||||||||||||||||||||||
| 1427 | break; | - | ||||||||||||||||||||||||
| 1428 | } | - | ||||||||||||||||||||||||
| 1429 | - | |||||||||||||||||||||||||
| 1430 | - | |||||||||||||||||||||||||
| 1431 | - | |||||||||||||||||||||||||
| 1432 | QList<QGraphicsItem *> itemList = items(sourceRect, Qt::IntersectsItemBoundingRect); | - | ||||||||||||||||||||||||
| 1433 | QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()]; | - | ||||||||||||||||||||||||
| 1434 | int numItems = itemList.size(); | - | ||||||||||||||||||||||||
| 1435 | for (int i = 0; i < numItems; ++i) | - | ||||||||||||||||||||||||
| 1436 | itemArray[numItems - i - 1] = itemList.at(i); | - | ||||||||||||||||||||||||
| 1437 | itemList.clear(); | - | ||||||||||||||||||||||||
| 1438 | - | |||||||||||||||||||||||||
| 1439 | painter->save(); | - | ||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||
| 1441 | - | |||||||||||||||||||||||||
| 1442 | painter->setClipRect(targetRect, Qt::IntersectClip); | - | ||||||||||||||||||||||||
| 1443 | QTransform painterTransform; | - | ||||||||||||||||||||||||
| 1444 | painterTransform *= QTransform() | - | ||||||||||||||||||||||||
| 1445 | .translate(targetRect.left(), targetRect.top()) | - | ||||||||||||||||||||||||
| 1446 | .scale(xratio, yratio) | - | ||||||||||||||||||||||||
| 1447 | .translate(-sourceRect.left(), -sourceRect.top()); | - | ||||||||||||||||||||||||
| 1448 | painter->setWorldTransform(painterTransform, true); | - | ||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||
| 1450 | - | |||||||||||||||||||||||||
| 1451 | QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems]; | - | ||||||||||||||||||||||||
| 1452 | for (int i = 0; i < numItems; ++i) | - | ||||||||||||||||||||||||
| 1453 | itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect()); | - | ||||||||||||||||||||||||
| 1454 | - | |||||||||||||||||||||||||
| 1455 | - | |||||||||||||||||||||||||
| 1456 | drawBackground(painter, sourceRect); | - | ||||||||||||||||||||||||
| 1457 | drawItems(painter, numItems, itemArray, styleOptionArray); | - | ||||||||||||||||||||||||
| 1458 | drawForeground(painter, sourceRect); | - | ||||||||||||||||||||||||
| 1459 | - | |||||||||||||||||||||||||
| 1460 | delete [] itemArray; | - | ||||||||||||||||||||||||
| 1461 | delete [] styleOptionArray; | - | ||||||||||||||||||||||||
| 1462 | - | |||||||||||||||||||||||||
| 1463 | painter->restore(); | - | ||||||||||||||||||||||||
| 1464 | } | - | ||||||||||||||||||||||||
| 1465 | QGraphicsScene::ItemIndexMethod QGraphicsScene::itemIndexMethod() const | - | ||||||||||||||||||||||||
| 1466 | { | - | ||||||||||||||||||||||||
| 1467 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1468 | return d->indexMethod; | - | ||||||||||||||||||||||||
| 1469 | } | - | ||||||||||||||||||||||||
| 1470 | void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method) | - | ||||||||||||||||||||||||
| 1471 | { | - | ||||||||||||||||||||||||
| 1472 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1473 | if (d->indexMethod == method) | - | ||||||||||||||||||||||||
| 1474 | return; | - | ||||||||||||||||||||||||
| 1475 | - | |||||||||||||||||||||||||
| 1476 | d->indexMethod = method; | - | ||||||||||||||||||||||||
| 1477 | - | |||||||||||||||||||||||||
| 1478 | QList<QGraphicsItem *> oldItems = d->index->items(Qt::DescendingOrder); | - | ||||||||||||||||||||||||
| 1479 | delete d->index; | - | ||||||||||||||||||||||||
| 1480 | if (method == BspTreeIndex) | - | ||||||||||||||||||||||||
| 1481 | d->index = new QGraphicsSceneBspTreeIndex(this); | - | ||||||||||||||||||||||||
| 1482 | else | - | ||||||||||||||||||||||||
| 1483 | d->index = new QGraphicsSceneLinearIndex(this); | - | ||||||||||||||||||||||||
| 1484 | for (int i = oldItems.size() - 1; i >= 0; --i) | - | ||||||||||||||||||||||||
| 1485 | d->index->addItem(oldItems.at(i)); | - | ||||||||||||||||||||||||
| 1486 | } | - | ||||||||||||||||||||||||
| 1487 | int QGraphicsScene::bspTreeDepth() const | - | ||||||||||||||||||||||||
| 1488 | { | - | ||||||||||||||||||||||||
| 1489 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1490 | QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index); | - | ||||||||||||||||||||||||
| 1491 | return bspTree ? bspTree->bspTreeDepth() : 0; | - | ||||||||||||||||||||||||
| 1492 | } | - | ||||||||||||||||||||||||
| 1493 | void QGraphicsScene::setBspTreeDepth(int depth) | - | ||||||||||||||||||||||||
| 1494 | { | - | ||||||||||||||||||||||||
| 1495 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1496 | if (depth < 0) { | - | ||||||||||||||||||||||||
| 1497 | QMessageLogger(__FILE__, 19061917, __PRETTY_FUNCTION__).warning("QGraphicsScene::setBspTreeDepth: invalid depth %d ignored; must be >= 0", depth); | - | ||||||||||||||||||||||||
| 1498 | return; | - | ||||||||||||||||||||||||
| 1499 | } | - | ||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||
| 1501 | QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index); | - | ||||||||||||||||||||||||
| 1502 | if (!bspTree) { | - | ||||||||||||||||||||||||
| 1503 | QMessageLogger(__FILE__, 19121923, __PRETTY_FUNCTION__).warning("QGraphicsScene::setBspTreeDepth: can not apply if indexing method is not BSP"); | - | ||||||||||||||||||||||||
| 1504 | return; | - | ||||||||||||||||||||||||
| 1505 | } | - | ||||||||||||||||||||||||
| 1506 | bspTree->setBspTreeDepth(depth); | - | ||||||||||||||||||||||||
| 1507 | } | - | ||||||||||||||||||||||||
| 1508 | bool QGraphicsScene::isSortCacheEnabled() const | - | ||||||||||||||||||||||||
| 1509 | { | - | ||||||||||||||||||||||||
| 1510 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1511 | return d->sortCacheEnabled; | - | ||||||||||||||||||||||||
| 1512 | } | - | ||||||||||||||||||||||||
| 1513 | void QGraphicsScene::setSortCacheEnabled(bool enabled) | - | ||||||||||||||||||||||||
| 1514 | { | - | ||||||||||||||||||||||||
| 1515 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1516 | if (d->sortCacheEnabled == enabled) | - | ||||||||||||||||||||||||
| 1517 | return; | - | ||||||||||||||||||||||||
| 1518 | d->sortCacheEnabled = enabled; | - | ||||||||||||||||||||||||
| 1519 | } | - | ||||||||||||||||||||||||
| 1520 | QRectF QGraphicsScene::itemsBoundingRect() const | - | ||||||||||||||||||||||||
| 1521 | { | - | ||||||||||||||||||||||||
| 1522 | - | |||||||||||||||||||||||||
| 1523 | QRectF boundingRect; | - | ||||||||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items())>::type> _container_((items())); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||||||||
| 1524 | ++_container_.i, _container_.control ^const auto items_ = 1)items(); | - | ||||||||||||||||||||||||
| 1525 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items_) | - | ||||||||||||||||||||||||
| 1526 | boundingRect |= item->sceneBoundingRect(); never executed: boundingRect |= item->sceneBoundingRect(); | 0 | ||||||||||||||||||||||||
| 1527 | return never executed: boundingRect;return boundingRect;never executed: return boundingRect; | 0 | ||||||||||||||||||||||||
| 1528 | } | - | ||||||||||||||||||||||||
| 1529 | - | |||||||||||||||||||||||||
| 1530 | - | |||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||
| 1532 | - | |||||||||||||||||||||||||
| 1533 | - | |||||||||||||||||||||||||
| 1534 | - | |||||||||||||||||||||||||
| 1535 | - | |||||||||||||||||||||||||
| 1536 | QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const | - | ||||||||||||||||||||||||
| 1537 | { | - | ||||||||||||||||||||||||
| 1538 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1539 | return d->index->items(order); | - | ||||||||||||||||||||||||
| 1540 | } | - | ||||||||||||||||||||||||
| 1541 | QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, | - | ||||||||||||||||||||||||
| 1542 | Qt::SortOrder order, const QTransform &deviceTransform) const | - | ||||||||||||||||||||||||
| 1543 | { | - | ||||||||||||||||||||||||
| 1544 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1545 | return d->index->items(pos, mode, order, deviceTransform); | - | ||||||||||||||||||||||||
| 1546 | } | - | ||||||||||||||||||||||||
| 1547 | QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, | - | ||||||||||||||||||||||||
| 1548 | Qt::SortOrder order, const QTransform &deviceTransform) const | - | ||||||||||||||||||||||||
| 1549 | { | - | ||||||||||||||||||||||||
| 1550 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1551 | return d->index->items(rect, mode, order, deviceTransform); | - | ||||||||||||||||||||||||
| 1552 | } | - | ||||||||||||||||||||||||
| 1553 | QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, | - | ||||||||||||||||||||||||
| 1554 | Qt::SortOrder order, const QTransform &deviceTransform) const | - | ||||||||||||||||||||||||
| 1555 | { | - | ||||||||||||||||||||||||
| 1556 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1557 | return d->index->items(polygon, mode, order, deviceTransform); | - | ||||||||||||||||||||||||
| 1558 | } | - | ||||||||||||||||||||||||
| 1559 | QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, | - | ||||||||||||||||||||||||
| 1560 | Qt::SortOrder order, const QTransform &deviceTransform) const | - | ||||||||||||||||||||||||
| 1561 | { | - | ||||||||||||||||||||||||
| 1562 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1563 | return d->index->items(path, mode, order, deviceTransform); | - | ||||||||||||||||||||||||
| 1564 | } | - | ||||||||||||||||||||||||
| 1565 | QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item, | - | ||||||||||||||||||||||||
| 1566 | Qt::ItemSelectionMode mode) const | - | ||||||||||||||||||||||||
| 1567 | { | - | ||||||||||||||||||||||||
| 1568 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1569 | if (!item
| 0 | ||||||||||||||||||||||||
| 1570 | QMessageLogger(__FILE__, 21132125, __PRETTY_FUNCTION__).warning("QGraphicsScene::collidingItems: cannot find collisions for null item"); | - | ||||||||||||||||||||||||
| 1571 | return never executed: QList<QGraphicsItem *>();return QList<QGraphicsItem *>();never executed: return QList<QGraphicsItem *>(); | 0 | ||||||||||||||||||||||||
| 1572 | } | - | ||||||||||||||||||||||||
| 1573 | - | |||||||||||||||||||||||||
| 1574 | - | |||||||||||||||||||||||||
| 1575 | QList<QGraphicsItem *> tmp; | - | ||||||||||||||||||||||||
| 1576 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder))>::type> _container_((const auto itemsInVicinity = d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)); | - | ||||||||||||||||||||||||
| 1577 | for (QGraphicsItem *itemInVicinity = *_container_.i; _container_.control; _container_.control = 0: itemsInVicinity) { | - | ||||||||||||||||||||||||
| 1578 | if (item != itemInVicinity
| 0 | ||||||||||||||||||||||||
| 1579 | tmp << itemInVicinity; never executed: tmp << itemInVicinity; | 0 | ||||||||||||||||||||||||
| 1580 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1581 | return never executed: tmp;return tmp;never executed: return tmp; | 0 | ||||||||||||||||||||||||
| 1582 | } | - | ||||||||||||||||||||||||
| 1583 | QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const | - | ||||||||||||||||||||||||
| 1584 | { | - | ||||||||||||||||||||||||
| 1585 | const QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape, | - | ||||||||||||||||||||||||
| 1586 | Qt::DescendingOrder, deviceTransform); | - | ||||||||||||||||||||||||
| 1587 | return never executed: itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();never executed: return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first(); | 0 | ||||||||||||||||||||||||
| 1588 | } | - | ||||||||||||||||||||||||
| 1589 | QList<QGraphicsItem *> QGraphicsScene::selectedItems() const | - | ||||||||||||||||||||||||
| 1590 | { | - | ||||||||||||||||||||||||
| 1591 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1592 | - | |||||||||||||||||||||||||
| 1593 | - | |||||||||||||||||||||||||
| 1594 | QGraphicsScene *that = const_cast<QGraphicsScene *>(this); | - | ||||||||||||||||||||||||
| 1595 | QSet<QGraphicsItem *> actuallySelectedSet; | - | ||||||||||||||||||||||||
| 1596 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(that->d_func()->selectedItems)>::type> _container_((that->d_func()->selectedItems)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 1597 | if (item->isSelected()) | - | ||||||||||||||||||||||||
| 1598 | actuallySelectedSet << item; | - | ||||||||||||||||||||||||
| 1599 | } | - | ||||||||||||||||||||||||
| 1600 | - | |||||||||||||||||||||||||
| 1601 | that->d_func()->selectedItems = actuallySelectedSet; | - | ||||||||||||||||||||||||
| 1602 | - | |||||||||||||||||||||||||
| 1603 | return d->selectedItems.values(); | - | ||||||||||||||||||||||||
| 1604 | } | - | ||||||||||||||||||||||||
| 1605 | QPainterPath QGraphicsScene::selectionArea() const | - | ||||||||||||||||||||||||
| 1606 | { | - | ||||||||||||||||||||||||
| 1607 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1608 | return d->selectionArea; | - | ||||||||||||||||||||||||
| 1609 | } | - | ||||||||||||||||||||||||
| 1610 | void QGraphicsScene::setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform) | - | ||||||||||||||||||||||||
| 1611 | { | - | ||||||||||||||||||||||||
| 1612 | setSelectionArea(path, Qt::IntersectsItemShape, deviceTransform); | - | ||||||||||||||||||||||||
| 1613 | } | - | ||||||||||||||||||||||||
| 1614 | void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode, | - | ||||||||||||||||||||||||
| 1615 | const QTransform &deviceTransform) | - | ||||||||||||||||||||||||
| 1616 | { | - | ||||||||||||||||||||||||
| 1617 | setSelectionArea(path, Qt::ReplaceSelection, mode, deviceTransform); | - | ||||||||||||||||||||||||
| 1618 | } | - | ||||||||||||||||||||||||
| 1619 | void QGraphicsScene::setSelectionArea(const QPainterPath &path, | - | ||||||||||||||||||||||||
| 1620 | Qt::ItemSelectionOperation selectionOperation, | - | ||||||||||||||||||||||||
| 1621 | Qt::ItemSelectionMode mode, | - | ||||||||||||||||||||||||
| 1622 | const QTransform &deviceTransform) | - | ||||||||||||||||||||||||
| 1623 | { | - | ||||||||||||||||||||||||
| 1624 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1625 | - | |||||||||||||||||||||||||
| 1626 | - | |||||||||||||||||||||||||
| 1627 | - | |||||||||||||||||||||||||
| 1628 | - | |||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||
| 1630 | d->selectionArea = path; | - | ||||||||||||||||||||||||
| 1631 | - | |||||||||||||||||||||||||
| 1632 | QSet<QGraphicsItem *> unselectItems = d->selectedItems; | - | ||||||||||||||||||||||||
| 1633 | - | |||||||||||||||||||||||||
| 1634 | - | |||||||||||||||||||||||||
| 1635 | ++d->selectionChanging; | - | ||||||||||||||||||||||||
| 1636 | bool changed = false; | - | ||||||||||||||||||||||||
| 1637 | - | |||||||||||||||||||||||||
| 1638 | - | |||||||||||||||||||||||||
| 1639 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(const auto items (path, mode, Qt::DescendingOrder, deviceTransform))>::type> _container_((= this->items(path, mode, Qt::DescendingOrder, deviceTransform))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)); | - | ||||||||||||||||||||||||
| 1640 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) { | - | ||||||||||||||||||||||||
| 1641 | if (item->flags() & QGraphicsItem::ItemIsSelectable
| 0 | ||||||||||||||||||||||||
| 1642 | if (!item->isSelected()
| 0 | ||||||||||||||||||||||||
| 1643 | changed = true; never executed: changed = true; | 0 | ||||||||||||||||||||||||
| 1644 | unselectItems.remove(item); | - | ||||||||||||||||||||||||
| 1645 | item->setSelected(true); | - | ||||||||||||||||||||||||
| 1646 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1647 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1648 | - | |||||||||||||||||||||||||
| 1649 | switch (selectionOperation) { | - | ||||||||||||||||||||||||
| 1650 | case never executed: Qt::ReplaceSelection:case Qt::ReplaceSelection:never executed: case Qt::ReplaceSelection: | 0 | ||||||||||||||||||||||||
| 1651 | - | |||||||||||||||||||||||||
| 1652 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(unselectItems)>::type> _container_((unselectItems)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 1653 | item->setSelected(false); | - | ||||||||||||||||||||||||
| 1654 | changed = true; | - | ||||||||||||||||||||||||
| 1655 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1656 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1657 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 1658 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1659 | } | - | ||||||||||||||||||||||||
| 1660 | - | |||||||||||||||||||||||||
| 1661 | - | |||||||||||||||||||||||||
| 1662 | --d->selectionChanging; | - | ||||||||||||||||||||||||
| 1663 | - | |||||||||||||||||||||||||
| 1664 | if (!d->selectionChanging
| 0 | ||||||||||||||||||||||||
| 1665 | selectionChanged(); never executed: selectionChanged(); | 0 | ||||||||||||||||||||||||
| 1666 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1667 | - | |||||||||||||||||||||||||
| 1668 | - | |||||||||||||||||||||||||
| 1669 | - | |||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||
| 1671 | - | |||||||||||||||||||||||||
| 1672 | - | |||||||||||||||||||||||||
| 1673 | void QGraphicsScene::clearSelection() | - | ||||||||||||||||||||||||
| 1674 | { | - | ||||||||||||||||||||||||
| 1675 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1676 | - | |||||||||||||||||||||||||
| 1677 | - | |||||||||||||||||||||||||
| 1678 | ++d->selectionChanging; | - | ||||||||||||||||||||||||
| 1679 | bool changed = !d->selectedItems.isEmpty(); | - | ||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||
| 1681 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->selectedItems)>::type> _container_((d->selectedItems)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
| 1682 | item->setSelected(false); | - | ||||||||||||||||||||||||
| 1683 | d->selectedItems.clear(); | - | ||||||||||||||||||||||||
| 1684 | - | |||||||||||||||||||||||||
| 1685 | - | |||||||||||||||||||||||||
| 1686 | --d->selectionChanging; | - | ||||||||||||||||||||||||
| 1687 | - | |||||||||||||||||||||||||
| 1688 | if (!d->selectionChanging && changed) | - | ||||||||||||||||||||||||
| 1689 | selectionChanged(); | - | ||||||||||||||||||||||||
| 1690 | } | - | ||||||||||||||||||||||||
| 1691 | void QGraphicsScene::clear() | - | ||||||||||||||||||||||||
| 1692 | { | - | ||||||||||||||||||||||||
| 1693 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1694 | - | |||||||||||||||||||||||||
| 1695 | - | |||||||||||||||||||||||||
| 1696 | d->index->clear(); | - | ||||||||||||||||||||||||
| 1697 | - | |||||||||||||||||||||||||
| 1698 | while (!d->topLevelItems.isEmpty()) | - | ||||||||||||||||||||||||
| 1699 | delete d->topLevelItems.first(); | - | ||||||||||||||||||||||||
| 1700 | ((!(d->topLevelItems.isEmpty())) ? qt_assert("d->topLevelItems.isEmpty()",__FILE__,23752389) : qt_noop()); | - | ||||||||||||||||||||||||
| 1701 | d->lastItemCount = 0; | - | ||||||||||||||||||||||||
| 1702 | d->allItemsIgnoreHoverEvents = true; | - | ||||||||||||||||||||||||
| 1703 | d->allItemsUseDefaultCursor = true; | - | ||||||||||||||||||||||||
| 1704 | d->allItemsIgnoreTouchEvents = true; | - | ||||||||||||||||||||||||
| 1705 | } | - | ||||||||||||||||||||||||
| 1706 | QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *> &items) | - | ||||||||||||||||||||||||
| 1707 | { | - | ||||||||||||||||||||||||
| 1708 | - | |||||||||||||||||||||||||
| 1709 | QList<QGraphicsItem *> ancestors; | - | ||||||||||||||||||||||||
| 1710 | int n = 0; | - | ||||||||||||||||||||||||
| 1711 | if (!items.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1712 | QGraphicsItem *parent = items.at(n++); | - | ||||||||||||||||||||||||
| 1713 | while ((
| 0 | ||||||||||||||||||||||||
| 1714 | ancestors.append(parent); never executed: ancestors.append(parent); | 0 | ||||||||||||||||||||||||
| 1715 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1716 | - | |||||||||||||||||||||||||
| 1717 | - | |||||||||||||||||||||||||
| 1718 | QGraphicsItem *commonAncestor = 0; | - | ||||||||||||||||||||||||
| 1719 | if (!ancestors.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1720 | while (n < items.size()
| 0 | ||||||||||||||||||||||||
| 1721 | int commonIndex = -1; | - | ||||||||||||||||||||||||
| 1722 | QGraphicsItem *parent = items.at(n++); | - | ||||||||||||||||||||||||
| 1723 | do { | - | ||||||||||||||||||||||||
| 1724 | int index = ancestors.indexOf(parent, qMax(0, commonIndex)); | - | ||||||||||||||||||||||||
| 1725 | if (index != -1
| 0 | ||||||||||||||||||||||||
| 1726 | commonIndex = index; | - | ||||||||||||||||||||||||
| 1727 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1728 | } | - | ||||||||||||||||||||||||
| 1729 | } never executed: while ((end of block
| 0 | ||||||||||||||||||||||||
| 1730 | - | |||||||||||||||||||||||||
| 1731 | if (commonIndex == -1
| 0 | ||||||||||||||||||||||||
| 1732 | commonAncestor = 0; | - | ||||||||||||||||||||||||
| 1733 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1734 | } | - | ||||||||||||||||||||||||
| 1735 | - | |||||||||||||||||||||||||
| 1736 | commonAncestor = ancestors.at(commonIndex); | - | ||||||||||||||||||||||||
| 1737 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1738 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1739 | - | |||||||||||||||||||||||||
| 1740 | - | |||||||||||||||||||||||||
| 1741 | QGraphicsItemGroup *group = new QGraphicsItemGroup(commonAncestor); | - | ||||||||||||||||||||||||
| 1742 | if (!commonAncestor
| 0 | ||||||||||||||||||||||||
| 1743 | addItem(group); never executed: addItem(group); | 0 | ||||||||||||||||||||||||
| 1744 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items)>::type> _container_((items)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) | - | ||||||||||||||||||||||||
| 1745 | group->addToGroup(item); never executed: group->addToGroup(item); | 0 | ||||||||||||||||||||||||
| 1746 | return never executed: group;return group;never executed: return group; | 0 | ||||||||||||||||||||||||
| 1747 | } | - | ||||||||||||||||||||||||
| 1748 | void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group) | - | ||||||||||||||||||||||||
| 1749 | { | - | ||||||||||||||||||||||||
| 1750 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(group->childItems())>::type> _container_((const auto items = group->childItems())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||||||||
| 1751 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) | - | ||||||||||||||||||||||||
| 1752 | group->removeFromGroup(item); never executed: group->removeFromGroup(item); | 0 | ||||||||||||||||||||||||
| 1753 | removeItem(group); | - | ||||||||||||||||||||||||
| 1754 | delete group; | - | ||||||||||||||||||||||||
| 1755 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1756 | void QGraphicsScene::addItem(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 1757 | { | - | ||||||||||||||||||||||||
| 1758 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1759 | if (!item
| 0 | ||||||||||||||||||||||||
| 1760 | QMessageLogger(__FILE__, 24822497, __PRETTY_FUNCTION__).warning("QGraphicsScene::addItem: cannot add null item"); | - | ||||||||||||||||||||||||
| 1761 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1762 | } | - | ||||||||||||||||||||||||
| 1763 | if (item->d_ptr->scene == this
| 0 | ||||||||||||||||||||||||
| 1764 | QMessageLogger(__FILE__, 24862501, __PRETTY_FUNCTION__).warning("QGraphicsScene::addItem: item has already been added to this scene"); | - | ||||||||||||||||||||||||
| 1765 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1766 | } | - | ||||||||||||||||||||||||
| 1767 | - | |||||||||||||||||||||||||
| 1768 | if (QGraphicsScene *oldScene = item->d_ptr->scene
| 0 | ||||||||||||||||||||||||
| 1769 | oldScene->removeItem(item); never executed: oldScene->removeItem(item); | 0 | ||||||||||||||||||||||||
| 1770 | - | |||||||||||||||||||||||||
| 1771 | - | |||||||||||||||||||||||||
| 1772 | - | |||||||||||||||||||||||||
| 1773 | const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange, | - | ||||||||||||||||||||||||
| 1774 | QVariant::fromValue<QGraphicsScene *>(this))); | - | ||||||||||||||||||||||||
| 1775 | QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant); | - | ||||||||||||||||||||||||
| 1776 | if (targetScene != this
| 0 | ||||||||||||||||||||||||
| 1777 | if (targetScene
| 0 | ||||||||||||||||||||||||
| 1778 | targetScene->addItem(item); never executed: targetScene->addItem(item); | 0 | ||||||||||||||||||||||||
| 1779 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1780 | } | - | ||||||||||||||||||||||||
| 1781 | - | |||||||||||||||||||||||||
| 1782 | - | |||||||||||||||||||||||||
| 1783 | - | |||||||||||||||||||||||||
| 1784 | if (!item->d_ptr->isDeclarativeItem
| 0 | ||||||||||||||||||||||||
| 1785 | if (d->unpolishedItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1786 | QMetaMethod method = metaObject()->method(d->polishItemsIndex); | - | ||||||||||||||||||||||||
| 1787 | method.invoke(this, Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 1788 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1789 | d->unpolishedItems.append(item); | - | ||||||||||||||||||||||||
| 1790 | item->d_ptr->pendingPolish = true; | - | ||||||||||||||||||||||||
| 1791 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1792 | - | |||||||||||||||||||||||||
| 1793 | - | |||||||||||||||||||||||||
| 1794 | - | |||||||||||||||||||||||||
| 1795 | if (QGraphicsItem *itemParent = item->d_ptr->parent
| 0 | ||||||||||||||||||||||||
| 1796 | if (itemParent->d_ptr->scene != this
| 0 | ||||||||||||||||||||||||
| 1797 | item->setParentItem(0); never executed: item->setParentItem(0); | 0 | ||||||||||||||||||||||||
| 1798 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1799 | - | |||||||||||||||||||||||||
| 1800 | - | |||||||||||||||||||||||||
| 1801 | item->d_func()->scene = targetScene; | - | ||||||||||||||||||||||||
| 1802 | - | |||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||
| 1804 | d->index->addItem(item); | - | ||||||||||||||||||||||||
| 1805 | - | |||||||||||||||||||||||||
| 1806 | - | |||||||||||||||||||||||||
| 1807 | if (!item->d_ptr->parent
| 0 | ||||||||||||||||||||||||
| 1808 | d->registerTopLevelItem(item); never executed: d->registerTopLevelItem(item); | 0 | ||||||||||||||||||||||||
| 1809 | - | |||||||||||||||||||||||||
| 1810 | - | |||||||||||||||||||||||||
| 1811 | - | |||||||||||||||||||||||||
| 1812 | - | |||||||||||||||||||||||||
| 1813 | d->markDirty(item); | - | ||||||||||||||||||||||||
| 1814 | d->dirtyGrowingItemsBoundingRect = true; | - | ||||||||||||||||||||||||
| 1815 | - | |||||||||||||||||||||||||
| 1816 | - | |||||||||||||||||||||||||
| 1817 | ++d->selectionChanging; | - | ||||||||||||||||||||||||
| 1818 | int oldSelectedItemSize = d->selectedItems.size(); | - | ||||||||||||||||||||||||
| 1819 | - | |||||||||||||||||||||||||
| 1820 | - | |||||||||||||||||||||||||
| 1821 | if (d->allItemsIgnoreHoverEvents
| 0 | ||||||||||||||||||||||||
| 1822 | d->allItemsIgnoreHoverEvents = false; | - | ||||||||||||||||||||||||
| 1823 | d->enableMouseTrackingOnViews(); | - | ||||||||||||||||||||||||
| 1824 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1825 | - | |||||||||||||||||||||||||
| 1826 | if (d->allItemsUseDefaultCursor
| 0 | ||||||||||||||||||||||||
| 1827 | d->allItemsUseDefaultCursor = false; | - | ||||||||||||||||||||||||
| 1828 | if (d->allItemsIgnoreHoverEvents
| 0 | ||||||||||||||||||||||||
| 1829 | d->enableMouseTrackingOnViews(); never executed: d->enableMouseTrackingOnViews(); | 0 | ||||||||||||||||||||||||
| 1830 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1831 | - | |||||||||||||||||||||||||
| 1832 | - | |||||||||||||||||||||||||
| 1833 | - | |||||||||||||||||||||||||
| 1834 | if (d->allItemsIgnoreTouchEvents
| 0 | ||||||||||||||||||||||||
| 1835 | d->allItemsIgnoreTouchEvents = false; | - | ||||||||||||||||||||||||
| 1836 | d->enableTouchEventsOnViews(); | - | ||||||||||||||||||||||||
| 1837 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1838 | - | |||||||||||||||||||||||||
| 1839 | - | |||||||||||||||||||||||||
| 1840 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(item->d_ptr->gestureContext.keys())>::type> _container_((const auto gestures = item->d_ptr->gestureContext.keys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||||||||
| 1841 | for (Qt::GestureType gesture = *_container_.i; _container_.control; _container_.control = 0: gestures) | - | ||||||||||||||||||||||||
| 1842 | d->grabGesture(item, gesture); never executed: d->grabGesture(item, gesture); | 0 | ||||||||||||||||||||||||
| 1843 | - | |||||||||||||||||||||||||
| 1844 | - | |||||||||||||||||||||||||
| 1845 | - | |||||||||||||||||||||||||
| 1846 | if (item->isSelected()
| 0 | ||||||||||||||||||||||||
| 1847 | d->selectedItems << item; never executed: d->selectedItems << item; | 0 | ||||||||||||||||||||||||
| 1848 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
| 1849 | d->addPopup(static_cast<QGraphicsWidget *>(item)); never executed: d->addPopup(static_cast<QGraphicsWidget *>(item)); | 0 | ||||||||||||||||||||||||
| 1850 | if (item->isPanel()
| 0 | ||||||||||||||||||||||||
| 1851 | d->enterModal(item); never executed: d->enterModal(item); | 0 | ||||||||||||||||||||||||
| 1852 | - | |||||||||||||||||||||||||
| 1853 | - | |||||||||||||||||||||||||
| 1854 | - | |||||||||||||||||||||||||
| 1855 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
| 1856 | QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
| 1857 | if (!d->tabFocusFirst
| 0 | ||||||||||||||||||||||||
| 1858 | - | |||||||||||||||||||||||||
| 1859 | - | |||||||||||||||||||||||||
| 1860 | d->tabFocusFirst = widget; | - | ||||||||||||||||||||||||
| 1861 | } never executed: else if (!widget->parentWidget()end of block
| 0 | ||||||||||||||||||||||||
| 1862 | - | |||||||||||||||||||||||||
| 1863 | QGraphicsWidget *myNewPrev = d->tabFocusFirst->d_func()->focusPrev; | - | ||||||||||||||||||||||||
| 1864 | myNewPrev->d_func()->focusNext = widget; | - | ||||||||||||||||||||||||
| 1865 | widget->d_func()->focusPrev->d_func()->focusNext = d->tabFocusFirst; | - | ||||||||||||||||||||||||
| 1866 | d->tabFocusFirst->d_func()->focusPrev = widget->d_func()->focusPrev; | - | ||||||||||||||||||||||||
| 1867 | widget->d_func()->focusPrev = myNewPrev; | - | ||||||||||||||||||||||||
| 1868 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1869 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1870 | - | |||||||||||||||||||||||||
| 1871 | - | |||||||||||||||||||||||||
| 1872 | item->d_ptr->ensureSortedChildren(); | - | ||||||||||||||||||||||||
| 1873 | for (int i = 0; i < item->d_ptr->children.size()
| 0 | ||||||||||||||||||||||||
| 1874 | addItem(item->d_ptr->children.at(i)); never executed: addItem(item->d_ptr->children.at(i)); | 0 | ||||||||||||||||||||||||
| 1875 | - | |||||||||||||||||||||||||
| 1876 | - | |||||||||||||||||||||||||
| 1877 | item->d_ptr->resolveFont(d->font.resolve()); | - | ||||||||||||||||||||||||
| 1878 | item->d_ptr->resolvePalette(d->palette.resolve()); | - | ||||||||||||||||||||||||
| 1879 | - | |||||||||||||||||||||||||
| 1880 | - | |||||||||||||||||||||||||
| 1881 | - | |||||||||||||||||||||||||
| 1882 | --d->selectionChanging; | - | ||||||||||||||||||||||||
| 1883 | if (!d->selectionChanging
| 0 | ||||||||||||||||||||||||
| 1884 | selectionChanged(); never executed: selectionChanged(); | 0 | ||||||||||||||||||||||||
| 1885 | - | |||||||||||||||||||||||||
| 1886 | - | |||||||||||||||||||||||||
| 1887 | item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant); | - | ||||||||||||||||||||||||
| 1888 | - | |||||||||||||||||||||||||
| 1889 | - | |||||||||||||||||||||||||
| 1890 | bool autoActivate = true; | - | ||||||||||||||||||||||||
| 1891 | if (!d->childExplicitActivation
| 0 | ||||||||||||||||||||||||
| 1892 | d->childExplicitActivation = item->d_ptr->wantsActive
never executed: d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2; | 0 | ||||||||||||||||||||||||
| 1893 | if (d->childExplicitActivation
| 0 | ||||||||||||||||||||||||
| 1894 | if (d->childExplicitActivation == 1
| 0 | ||||||||||||||||||||||||
| 1895 | setActivePanel(item); never executed: setActivePanel(item); | 0 | ||||||||||||||||||||||||
| 1896 | else | - | ||||||||||||||||||||||||
| 1897 | autoActivate = false; never executed: autoActivate = false; | 0 | ||||||||||||||||||||||||
| 1898 | d->childExplicitActivation = 0; | - | ||||||||||||||||||||||||
| 1899 | } never executed: else if (!item->d_ptr->parentend of block
| 0 | ||||||||||||||||||||||||
| 1900 | d->childExplicitActivation = 0; | - | ||||||||||||||||||||||||
| 1901 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1902 | - | |||||||||||||||||||||||||
| 1903 | - | |||||||||||||||||||||||||
| 1904 | if (autoActivate
| 0 | ||||||||||||||||||||||||
| 1905 | if (!d->lastActivePanel
| 0 | ||||||||||||||||||||||||
| 1906 | if (isActive()
| 0 | ||||||||||||||||||||||||
| 1907 | setActivePanel(item); never executed: setActivePanel(item); | 0 | ||||||||||||||||||||||||
| 1908 | else | - | ||||||||||||||||||||||||
| 1909 | d->lastActivePanel = item; never executed: d->lastActivePanel = item; | 0 | ||||||||||||||||||||||||
| 1910 | } | - | ||||||||||||||||||||||||
| 1911 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1912 | - | |||||||||||||||||||||||||
| 1913 | if (item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges
| 0 | ||||||||||||||||||||||||
| 1914 | d->registerScenePosItem(item); never executed: d->registerScenePosItem(item); | 0 | ||||||||||||||||||||||||
| 1915 | - | |||||||||||||||||||||||||
| 1916 | - | |||||||||||||||||||||||||
| 1917 | - | |||||||||||||||||||||||||
| 1918 | if (!d->focusItem
| 0 | ||||||||||||||||||||||||
| 1919 | item->focusItem()->setFocus(); never executed: item->focusItem()->setFocus(); | 0 | ||||||||||||||||||||||||
| 1920 | - | |||||||||||||||||||||||||
| 1921 | d->updateInputMethodSensitivityInViews(); | - | ||||||||||||||||||||||||
| 1922 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1923 | QGraphicsEllipseItem *QGraphicsScene::addEllipse(const QRectF &rect, const QPen &pen, const QBrush &brush) | - | ||||||||||||||||||||||||
| 1924 | { | - | ||||||||||||||||||||||||
| 1925 | QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect); | - | ||||||||||||||||||||||||
| 1926 | item->setPen(pen); | - | ||||||||||||||||||||||||
| 1927 | item->setBrush(brush); | - | ||||||||||||||||||||||||
| 1928 | addItem(item); | - | ||||||||||||||||||||||||
| 1929 | return item; | - | ||||||||||||||||||||||||
| 1930 | } | - | ||||||||||||||||||||||||
| 1931 | QGraphicsLineItem *QGraphicsScene::addLine(const QLineF &line, const QPen &pen) | - | ||||||||||||||||||||||||
| 1932 | { | - | ||||||||||||||||||||||||
| 1933 | QGraphicsLineItem *item = new QGraphicsLineItem(line); | - | ||||||||||||||||||||||||
| 1934 | item->setPen(pen); | - | ||||||||||||||||||||||||
| 1935 | addItem(item); | - | ||||||||||||||||||||||||
| 1936 | return item; | - | ||||||||||||||||||||||||
| 1937 | } | - | ||||||||||||||||||||||||
| 1938 | QGraphicsPathItem *QGraphicsScene::addPath(const QPainterPath &path, const QPen &pen, const QBrush &brush) | - | ||||||||||||||||||||||||
| 1939 | { | - | ||||||||||||||||||||||||
| 1940 | QGraphicsPathItem *item = new QGraphicsPathItem(path); | - | ||||||||||||||||||||||||
| 1941 | item->setPen(pen); | - | ||||||||||||||||||||||||
| 1942 | item->setBrush(brush); | - | ||||||||||||||||||||||||
| 1943 | addItem(item); | - | ||||||||||||||||||||||||
| 1944 | return item; | - | ||||||||||||||||||||||||
| 1945 | } | - | ||||||||||||||||||||||||
| 1946 | QGraphicsPixmapItem *QGraphicsScene::addPixmap(const QPixmap &pixmap) | - | ||||||||||||||||||||||||
| 1947 | { | - | ||||||||||||||||||||||||
| 1948 | QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap); | - | ||||||||||||||||||||||||
| 1949 | addItem(item); | - | ||||||||||||||||||||||||
| 1950 | return item; | - | ||||||||||||||||||||||||
| 1951 | } | - | ||||||||||||||||||||||||
| 1952 | QGraphicsPolygonItem *QGraphicsScene::addPolygon(const QPolygonF &polygon, | - | ||||||||||||||||||||||||
| 1953 | const QPen &pen, const QBrush &brush) | - | ||||||||||||||||||||||||
| 1954 | { | - | ||||||||||||||||||||||||
| 1955 | QGraphicsPolygonItem *item = new QGraphicsPolygonItem(polygon); | - | ||||||||||||||||||||||||
| 1956 | item->setPen(pen); | - | ||||||||||||||||||||||||
| 1957 | item->setBrush(brush); | - | ||||||||||||||||||||||||
| 1958 | addItem(item); | - | ||||||||||||||||||||||||
| 1959 | return item; | - | ||||||||||||||||||||||||
| 1960 | } | - | ||||||||||||||||||||||||
| 1961 | QGraphicsRectItem *QGraphicsScene::addRect(const QRectF &rect, const QPen &pen, const QBrush &brush) | - | ||||||||||||||||||||||||
| 1962 | { | - | ||||||||||||||||||||||||
| 1963 | QGraphicsRectItem *item = new QGraphicsRectItem(rect); | - | ||||||||||||||||||||||||
| 1964 | item->setPen(pen); | - | ||||||||||||||||||||||||
| 1965 | item->setBrush(brush); | - | ||||||||||||||||||||||||
| 1966 | addItem(item); | - | ||||||||||||||||||||||||
| 1967 | return item; | - | ||||||||||||||||||||||||
| 1968 | } | - | ||||||||||||||||||||||||
| 1969 | QGraphicsTextItem *QGraphicsScene::addText(const QString &text, const QFont &font) | - | ||||||||||||||||||||||||
| 1970 | { | - | ||||||||||||||||||||||||
| 1971 | QGraphicsTextItem *item = new QGraphicsTextItem(text); | - | ||||||||||||||||||||||||
| 1972 | item->setFont(font); | - | ||||||||||||||||||||||||
| 1973 | addItem(item); | - | ||||||||||||||||||||||||
| 1974 | return item; | - | ||||||||||||||||||||||||
| 1975 | } | - | ||||||||||||||||||||||||
| 1976 | QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, const QFont &font) | - | ||||||||||||||||||||||||
| 1977 | { | - | ||||||||||||||||||||||||
| 1978 | QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text); | - | ||||||||||||||||||||||||
| 1979 | item->setFont(font); | - | ||||||||||||||||||||||||
| 1980 | addItem(item); | - | ||||||||||||||||||||||||
| 1981 | return item; | - | ||||||||||||||||||||||||
| 1982 | } | - | ||||||||||||||||||||||||
| 1983 | QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags) | - | ||||||||||||||||||||||||
| 1984 | { | - | ||||||||||||||||||||||||
| 1985 | QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags); | - | ||||||||||||||||||||||||
| 1986 | proxy->setWidget(widget); | - | ||||||||||||||||||||||||
| 1987 | addItem(proxy); | - | ||||||||||||||||||||||||
| 1988 | return proxy; | - | ||||||||||||||||||||||||
| 1989 | } | - | ||||||||||||||||||||||||
| 1990 | void QGraphicsScene::removeItem(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 1991 | { | - | ||||||||||||||||||||||||
| 1992 | - | |||||||||||||||||||||||||
| 1993 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 1994 | if (!item) { | - | ||||||||||||||||||||||||
| 1995 | QMessageLogger(__FILE__, 28942910, __PRETTY_FUNCTION__).warning("QGraphicsScene::removeItem: cannot remove 0-item"); | - | ||||||||||||||||||||||||
| 1996 | return; | - | ||||||||||||||||||||||||
| 1997 | } | - | ||||||||||||||||||||||||
| 1998 | if (item->scene() != this) { | - | ||||||||||||||||||||||||
| 1999 | QMessageLogger(__FILE__, 28982914, __PRETTY_FUNCTION__).warning("QGraphicsScene::removeItem: item %p's scene (%p)" | - | ||||||||||||||||||||||||
| 2000 | " is different from this scene (%p)", | - | ||||||||||||||||||||||||
| 2001 | item, item->scene(), this); | - | ||||||||||||||||||||||||
| 2002 | return; | - | ||||||||||||||||||||||||
| 2003 | } | - | ||||||||||||||||||||||||
| 2004 | - | |||||||||||||||||||||||||
| 2005 | - | |||||||||||||||||||||||||
| 2006 | - | |||||||||||||||||||||||||
| 2007 | const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange, | - | ||||||||||||||||||||||||
| 2008 | QVariant::fromValue<QGraphicsScene *>(0))); | - | ||||||||||||||||||||||||
| 2009 | QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant); | - | ||||||||||||||||||||||||
| 2010 | if (targetScene != 0 && targetScene != this) { | - | ||||||||||||||||||||||||
| 2011 | targetScene->addItem(item); | - | ||||||||||||||||||||||||
| 2012 | return; | - | ||||||||||||||||||||||||
| 2013 | } | - | ||||||||||||||||||||||||
| 2014 | - | |||||||||||||||||||||||||
| 2015 | d->removeItemHelper(item); | - | ||||||||||||||||||||||||
| 2016 | - | |||||||||||||||||||||||||
| 2017 | - | |||||||||||||||||||||||||
| 2018 | item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant); | - | ||||||||||||||||||||||||
| 2019 | - | |||||||||||||||||||||||||
| 2020 | d->updateInputMethodSensitivityInViews(); | - | ||||||||||||||||||||||||
| 2021 | } | - | ||||||||||||||||||||||||
| 2022 | QGraphicsItem *QGraphicsScene::focusItem() const | - | ||||||||||||||||||||||||
| 2023 | { | - | ||||||||||||||||||||||||
| 2024 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2025 | return isActive() ? d->focusItem : d->passiveFocusItem; | - | ||||||||||||||||||||||||
| 2026 | } | - | ||||||||||||||||||||||||
| 2027 | void QGraphicsScene::setFocusItem(QGraphicsItem *item, Qt::FocusReason focusReason) | - | ||||||||||||||||||||||||
| 2028 | { | - | ||||||||||||||||||||||||
| 2029 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2030 | if (item) | - | ||||||||||||||||||||||||
| 2031 | item->setFocus(focusReason); | - | ||||||||||||||||||||||||
| 2032 | else | - | ||||||||||||||||||||||||
| 2033 | d->setFocusItemHelper(item, focusReason); | - | ||||||||||||||||||||||||
| 2034 | } | - | ||||||||||||||||||||||||
| 2035 | bool QGraphicsScene::hasFocus() const | - | ||||||||||||||||||||||||
| 2036 | { | - | ||||||||||||||||||||||||
| 2037 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2038 | return d->hasFocus; | - | ||||||||||||||||||||||||
| 2039 | } | - | ||||||||||||||||||||||||
| 2040 | void QGraphicsScene::setFocus(Qt::FocusReason focusReason) | - | ||||||||||||||||||||||||
| 2041 | { | - | ||||||||||||||||||||||||
| 2042 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2043 | if (d->hasFocus || !isActive()) | - | ||||||||||||||||||||||||
| 2044 | return; | - | ||||||||||||||||||||||||
| 2045 | QFocusEvent event(QEvent::FocusIn, focusReason); | - | ||||||||||||||||||||||||
| 2046 | QCoreApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||
| 2047 | } | - | ||||||||||||||||||||||||
| 2048 | void QGraphicsScene::clearFocus() | - | ||||||||||||||||||||||||
| 2049 | { | - | ||||||||||||||||||||||||
| 2050 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2051 | if (d->hasFocus) { | - | ||||||||||||||||||||||||
| 2052 | d->hasFocus = false; | - | ||||||||||||||||||||||||
| 2053 | d->passiveFocusItem = d->focusItem; | - | ||||||||||||||||||||||||
| 2054 | setFocusItem(0, Qt::OtherFocusReason); | - | ||||||||||||||||||||||||
| 2055 | } | - | ||||||||||||||||||||||||
| 2056 | } | - | ||||||||||||||||||||||||
| 2057 | void QGraphicsScene::setStickyFocus(bool enabled) | - | ||||||||||||||||||||||||
| 2058 | { | - | ||||||||||||||||||||||||
| 2059 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2060 | d->stickyFocus = enabled; | - | ||||||||||||||||||||||||
| 2061 | } | - | ||||||||||||||||||||||||
| 2062 | bool QGraphicsScene::stickyFocus() const | - | ||||||||||||||||||||||||
| 2063 | { | - | ||||||||||||||||||||||||
| 2064 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2065 | return d->stickyFocus; | - | ||||||||||||||||||||||||
| 2066 | } | - | ||||||||||||||||||||||||
| 2067 | QGraphicsItem *QGraphicsScene::mouseGrabberItem() const | - | ||||||||||||||||||||||||
| 2068 | { | - | ||||||||||||||||||||||||
| 2069 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2070 | return !d->mouseGrabberItems.isEmpty() ? d->mouseGrabberItems.last() : 0; | - | ||||||||||||||||||||||||
| 2071 | } | - | ||||||||||||||||||||||||
| 2072 | QBrush QGraphicsScene::backgroundBrush() const | - | ||||||||||||||||||||||||
| 2073 | { | - | ||||||||||||||||||||||||
| 2074 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2075 | return d->backgroundBrush; | - | ||||||||||||||||||||||||
| 2076 | } | - | ||||||||||||||||||||||||
| 2077 | void QGraphicsScene::setBackgroundBrush(const QBrush &brush) | - | ||||||||||||||||||||||||
| 2078 | { | - | ||||||||||||||||||||||||
| 2079 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2080 | d->backgroundBrush = brush; | - | ||||||||||||||||||||||||
| 2081 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->views)>::type> _container_((d->views)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsView *view = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 2082 | view->resetCachedContent(); | - | ||||||||||||||||||||||||
| 2083 | view->viewport()->update(); | - | ||||||||||||||||||||||||
| 2084 | } | - | ||||||||||||||||||||||||
| 2085 | update(); | - | ||||||||||||||||||||||||
| 2086 | } | - | ||||||||||||||||||||||||
| 2087 | QBrush QGraphicsScene::foregroundBrush() const | - | ||||||||||||||||||||||||
| 2088 | { | - | ||||||||||||||||||||||||
| 2089 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2090 | return d->foregroundBrush; | - | ||||||||||||||||||||||||
| 2091 | } | - | ||||||||||||||||||||||||
| 2092 | void QGraphicsScene::setForegroundBrush(const QBrush &brush) | - | ||||||||||||||||||||||||
| 2093 | { | - | ||||||||||||||||||||||||
| 2094 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2095 | d->foregroundBrush = brush; | - | ||||||||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(views())>::type> _container_((views())); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||||||||
| 2096 | ++_container_.i, _container_.control ^const auto views_ = 1)views(); | - | ||||||||||||||||||||||||
| 2097 | for (QGraphicsView *view = *_container_.i; _container_.control; _container_.control = 0: views_) | - | ||||||||||||||||||||||||
| 2098 | view->viewport()->update(); never executed: view->viewport()->update(); | 0 | ||||||||||||||||||||||||
| 2099 | update(); | - | ||||||||||||||||||||||||
| 2100 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2101 | QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const | - | ||||||||||||||||||||||||
| 2102 | { | - | ||||||||||||||||||||||||
| 2103 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2104 | if (!d->focusItem || !(d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) | - | ||||||||||||||||||||||||
| 2105 | return QVariant(); | - | ||||||||||||||||||||||||
| 2106 | const QTransform matrix = d->focusItem->sceneTransform(); | - | ||||||||||||||||||||||||
| 2107 | QVariant value = d->focusItem->inputMethodQuery(query); | - | ||||||||||||||||||||||||
| 2108 | if (value.type() == QVariant::RectF) | - | ||||||||||||||||||||||||
| 2109 | value = matrix.mapRect(value.toRectF()); | - | ||||||||||||||||||||||||
| 2110 | else if (value.type() == QVariant::PointF) | - | ||||||||||||||||||||||||
| 2111 | value = matrix.map(value.toPointF()); | - | ||||||||||||||||||||||||
| 2112 | else if (value.type() == QVariant::Rect) | - | ||||||||||||||||||||||||
| 2113 | value = matrix.mapRect(value.toRect()); | - | ||||||||||||||||||||||||
| 2114 | else if (value.type() == QVariant::Point) | - | ||||||||||||||||||||||||
| 2115 | value = matrix.map(value.toPoint()); | - | ||||||||||||||||||||||||
| 2116 | return value; | - | ||||||||||||||||||||||||
| 2117 | } | - | ||||||||||||||||||||||||
| 2118 | - | |||||||||||||||||||||||||
| 2119 | - | |||||||||||||||||||||||||
| 2120 | - | |||||||||||||||||||||||||
| 2121 | - | |||||||||||||||||||||||||
| 2122 | - | |||||||||||||||||||||||||
| 2123 | - | |||||||||||||||||||||||||
| 2124 | - | |||||||||||||||||||||||||
| 2125 | void QGraphicsScene::update(const QRectF &rect) | - | ||||||||||||||||||||||||
| 2126 | { | - | ||||||||||||||||||||||||
| 2127 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2128 | if (d->updateAll || (rect.isEmpty() && !rect.isNull())) | - | ||||||||||||||||||||||||
| 2129 | return; | - | ||||||||||||||||||||||||
| 2130 | - | |||||||||||||||||||||||||
| 2131 | - | |||||||||||||||||||||||||
| 2132 | - | |||||||||||||||||||||||||
| 2133 | bool directUpdates = !(d->isSignalConnected(d->changedSignalIndex)) && !d->views.isEmpty(); | - | ||||||||||||||||||||||||
| 2134 | if (rect.isNull()) { | - | ||||||||||||||||||||||||
| 2135 | d->updateAll = true; | - | ||||||||||||||||||||||||
| 2136 | d->updatedRects.clear(); | - | ||||||||||||||||||||||||
| 2137 | if (directUpdates) { | - | ||||||||||||||||||||||||
| 2138 | - | |||||||||||||||||||||||||
| 2139 | for (int i = 0; i < d->views.size(); ++i) | - | ||||||||||||||||||||||||
| 2140 | d->views.at(i)->d_func()->fullUpdatePending = true; | - | ||||||||||||||||||||||||
| 2141 | } | - | ||||||||||||||||||||||||
| 2142 | } else { | - | ||||||||||||||||||||||||
| 2143 | if (directUpdates) { | - | ||||||||||||||||||||||||
| 2144 | - | |||||||||||||||||||||||||
| 2145 | for (int i = 0; i < d->views.size(); ++i) { | - | ||||||||||||||||||||||||
| 2146 | QGraphicsView *view = d->views.at(i); | - | ||||||||||||||||||||||||
| 2147 | if (view->isTransformed()) | - | ||||||||||||||||||||||||
| 2148 | view->d_func()->updateRectF(view->viewportTransform().mapRect(rect)); | - | ||||||||||||||||||||||||
| 2149 | else | - | ||||||||||||||||||||||||
| 2150 | view->d_func()->updateRectF(rect); | - | ||||||||||||||||||||||||
| 2151 | } | - | ||||||||||||||||||||||||
| 2152 | } else { | - | ||||||||||||||||||||||||
| 2153 | d->updatedRects << rect; | - | ||||||||||||||||||||||||
| 2154 | } | - | ||||||||||||||||||||||||
| 2155 | } | - | ||||||||||||||||||||||||
| 2156 | - | |||||||||||||||||||||||||
| 2157 | if (!d->calledEmitUpdated) { | - | ||||||||||||||||||||||||
| 2158 | d->calledEmitUpdated = true; | - | ||||||||||||||||||||||||
| 2159 | QMetaObject::invokeMethod(this, "_q_emitUpdated", Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 2160 | } | - | ||||||||||||||||||||||||
| 2161 | } | - | ||||||||||||||||||||||||
| 2162 | void QGraphicsScene::invalidate(const QRectF &rect, SceneLayers layers) | - | ||||||||||||||||||||||||
| 2163 | { | - | ||||||||||||||||||||||||
| 2164 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(views())>::type> _container_((views())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^const auto views_ = 1)views(); | - | ||||||||||||||||||||||||
| 2165 | for (QGraphicsView *view = *_container_.i; _container_.control; _container_.control = 0: views_) | - | ||||||||||||||||||||||||
| 2166 | view->invalidateScene(rect, layers); never executed: view->invalidateScene(rect, layers); | 0 | ||||||||||||||||||||||||
| 2167 | update(rect); | - | ||||||||||||||||||||||||
| 2168 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2169 | QList <QGraphicsView *> QGraphicsScene::views() const | - | ||||||||||||||||||||||||
| 2170 | { | - | ||||||||||||||||||||||||
| 2171 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2172 | return d->views; | - | ||||||||||||||||||||||||
| 2173 | } | - | ||||||||||||||||||||||||
| 2174 | void QGraphicsScene::advance() | - | ||||||||||||||||||||||||
| 2175 | { | - | ||||||||||||||||||||||||
| 2176 | for (int i = 0; i < 2
| 0 | ||||||||||||||||||||||||
| 2177 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items())>::type> _container_((items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^const auto items_ = 1)items(); | - | ||||||||||||||||||||||||
| 2178 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items_) | - | ||||||||||||||||||||||||
| 2179 | item->advance(i); never executed: item->advance(i); | 0 | ||||||||||||||||||||||||
| 2180 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2181 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2182 | bool QGraphicsScene::event(QEvent *event) | - | ||||||||||||||||||||||||
| 2183 | { | - | ||||||||||||||||||||||||
| 2184 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2185 | - | |||||||||||||||||||||||||
| 2186 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 2187 | case never executed: QEvent::GraphicsSceneMousePress:case QEvent::GraphicsSceneMousePress:never executed: case QEvent::GraphicsSceneMousePress: | 0 | ||||||||||||||||||||||||
| 2188 | case never executed: QEvent::GraphicsSceneMouseMove:case QEvent::GraphicsSceneMouseMove:never executed: case QEvent::GraphicsSceneMouseMove: | 0 | ||||||||||||||||||||||||
| 2189 | case never executed: QEvent::GraphicsSceneMouseRelease:case QEvent::GraphicsSceneMouseRelease:never executed: case QEvent::GraphicsSceneMouseRelease: | 0 | ||||||||||||||||||||||||
| 2190 | case never executed: QEvent::GraphicsSceneMouseDoubleClick:case QEvent::GraphicsSceneMouseDoubleClick:never executed: case QEvent::GraphicsSceneMouseDoubleClick: | 0 | ||||||||||||||||||||||||
| 2191 | case never executed: QEvent::GraphicsSceneHoverEnter:case QEvent::GraphicsSceneHoverEnter:never executed: case QEvent::GraphicsSceneHoverEnter: | 0 | ||||||||||||||||||||||||
| 2192 | case never executed: QEvent::GraphicsSceneHoverLeave:case QEvent::GraphicsSceneHoverLeave:never executed: case QEvent::GraphicsSceneHoverLeave: | 0 | ||||||||||||||||||||||||
| 2193 | case never executed: QEvent::GraphicsSceneHoverMove:case QEvent::GraphicsSceneHoverMove:never executed: case QEvent::GraphicsSceneHoverMove: | 0 | ||||||||||||||||||||||||
| 2194 | case never executed: QEvent::TouchBegin:case QEvent::TouchBegin:never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||||||||
| 2195 | case never executed: QEvent::TouchUpdate:case QEvent::TouchUpdate:never executed: case QEvent::TouchUpdate: | 0 | ||||||||||||||||||||||||
| 2196 | case never executed: QEvent::TouchEnd:case QEvent::TouchEnd:never executed: case QEvent::TouchEnd: | 0 | ||||||||||||||||||||||||
| 2197 | - | |||||||||||||||||||||||||
| 2198 | - | |||||||||||||||||||||||||
| 2199 | - | |||||||||||||||||||||||||
| 2200 | - | |||||||||||||||||||||||||
| 2201 | - | |||||||||||||||||||||||||
| 2202 | - | |||||||||||||||||||||||||
| 2203 | - | |||||||||||||||||||||||||
| 2204 | d->cachedItemsUnderMouse.clear(); | - | ||||||||||||||||||||||||
| 2205 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
| 2206 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2207 | } | - | ||||||||||||||||||||||||
| 2208 | - | |||||||||||||||||||||||||
| 2209 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 2210 | case never executed: QEvent::GraphicsSceneDragEnter:case QEvent::GraphicsSceneDragEnter:never executed: case QEvent::GraphicsSceneDragEnter: | 0 | ||||||||||||||||||||||||
| 2211 | dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - | ||||||||||||||||||||||||
| 2212 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2213 | case never executed: QEvent::GraphicsSceneDragMove:case QEvent::GraphicsSceneDragMove:never executed: case QEvent::GraphicsSceneDragMove: | 0 | ||||||||||||||||||||||||
| 2214 | dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - | ||||||||||||||||||||||||
| 2215 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2216 | case never executed: QEvent::GraphicsSceneDragLeave:case QEvent::GraphicsSceneDragLeave:never executed: case QEvent::GraphicsSceneDragLeave: | 0 | ||||||||||||||||||||||||
| 2217 | dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - | ||||||||||||||||||||||||
| 2218 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2219 | case never executed: QEvent::GraphicsSceneDrop:case QEvent::GraphicsSceneDrop:never executed: case QEvent::GraphicsSceneDrop: | 0 | ||||||||||||||||||||||||
| 2220 | dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - | ||||||||||||||||||||||||
| 2221 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2222 | case never executed: QEvent::GraphicsSceneContextMenu:case QEvent::GraphicsSceneContextMenu:never executed: case QEvent::GraphicsSceneContextMenu: | 0 | ||||||||||||||||||||||||
| 2223 | contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event)); | - | ||||||||||||||||||||||||
| 2224 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2225 | case never executed: QEvent::KeyPress:case QEvent::KeyPress:never executed: case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||
| 2226 | if (!d->focusItem
| 0 | ||||||||||||||||||||||||
| 2227 | QKeyEvent *k = static_cast<QKeyEvent *>(event); | - | ||||||||||||||||||||||||
| 2228 | if (k->key() == Qt::Key_Tab
| 0 | ||||||||||||||||||||||||
| 2229 | if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))
| 0 | ||||||||||||||||||||||||
| 2230 | bool res = false; | - | ||||||||||||||||||||||||
| 2231 | if (k->key() == Qt::Key_Backtab
| 0 | ||||||||||||||||||||||||
| 2232 | || (k->key() == Qt::Key_Tab
| 0 | ||||||||||||||||||||||||
| 2233 | res = focusNextPrevChild(false); | - | ||||||||||||||||||||||||
| 2234 | } never executed: else if (k->key() == Qt::Key_Tabend of block
| 0 | ||||||||||||||||||||||||
| 2235 | res = focusNextPrevChild(true); | - | ||||||||||||||||||||||||
| 2236 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2237 | if (!res
| 0 | ||||||||||||||||||||||||
| 2238 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||
| 2239 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2240 | } | - | ||||||||||||||||||||||||
| 2241 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2243 | keyPressEvent(static_cast<QKeyEvent *>(event)); | - | ||||||||||||||||||||||||
| 2244 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2245 | case never executed: QEvent::KeyRelease:case QEvent::KeyRelease:never executed: case QEvent::KeyRelease: | 0 | ||||||||||||||||||||||||
| 2246 | keyReleaseEvent(static_cast<QKeyEvent *>(event)); | - | ||||||||||||||||||||||||
| 2247 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2248 | case never executed: QEvent::ShortcutOverride:case QEvent::ShortcutOverride:never executed: {case QEvent::ShortcutOverride: | 0 | ||||||||||||||||||||||||
| 2249 | QGraphicsItem *parent = focusItem(); | - | ||||||||||||||||||||||||
| 2250 | while (parent
| 0 | ||||||||||||||||||||||||
| 2251 | d->sendEvent(parent, event); | - | ||||||||||||||||||||||||
| 2252 | if (event->isAccepted()
| 0 | ||||||||||||||||||||||||
| 2253 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2254 | parent = parent->parentItem(); | - | ||||||||||||||||||||||||
| 2255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2256 | } | - | ||||||||||||||||||||||||
| 2257 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2258 | case never executed: QEvent::GraphicsSceneMouseMove:case QEvent::GraphicsSceneMouseMove:never executed: case QEvent::GraphicsSceneMouseMove: | 0 | ||||||||||||||||||||||||
| 2259 | { | - | ||||||||||||||||||||||||
| 2260 | QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event); | - | ||||||||||||||||||||||||
| 2261 | d->lastSceneMousePos = mouseEvent->scenePos(); | - | ||||||||||||||||||||||||
| 2262 | mouseMoveEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 2263 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2264 | } | - | ||||||||||||||||||||||||
| 2265 | case never executed: QEvent::GraphicsSceneMousePress:case QEvent::GraphicsSceneMousePress:never executed: case QEvent::GraphicsSceneMousePress: | 0 | ||||||||||||||||||||||||
| 2266 | mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - | ||||||||||||||||||||||||
| 2267 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2268 | case never executed: QEvent::GraphicsSceneMouseRelease:case QEvent::GraphicsSceneMouseRelease:never executed: case QEvent::GraphicsSceneMouseRelease: | 0 | ||||||||||||||||||||||||
| 2269 | mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - | ||||||||||||||||||||||||
| 2270 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2271 | case never executed: QEvent::GraphicsSceneMouseDoubleClick:case QEvent::GraphicsSceneMouseDoubleClick:never executed: case QEvent::GraphicsSceneMouseDoubleClick: | 0 | ||||||||||||||||||||||||
| 2272 | mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - | ||||||||||||||||||||||||
| 2273 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2274 | case never executed: QEvent::GraphicsSceneWheel:case QEvent::GraphicsSceneWheel:never executed: case QEvent::GraphicsSceneWheel: | 0 | ||||||||||||||||||||||||
| 2275 | wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event)); | - | ||||||||||||||||||||||||
| 2276 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2277 | case never executed: QEvent::FocusIn:case QEvent::FocusIn:never executed: case QEvent::FocusIn: | 0 | ||||||||||||||||||||||||
| 2278 | focusInEvent(static_cast<QFocusEvent *>(event)); | - | ||||||||||||||||||||||||
| 2279 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2280 | case never executed: QEvent::FocusOut:case QEvent::FocusOut:never executed: case QEvent::FocusOut: | 0 | ||||||||||||||||||||||||
| 2281 | focusOutEvent(static_cast<QFocusEvent *>(event)); | - | ||||||||||||||||||||||||
| 2282 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2283 | case never executed: QEvent::GraphicsSceneHoverEnter:case QEvent::GraphicsSceneHoverEnter:never executed: case QEvent::GraphicsSceneHoverEnter: | 0 | ||||||||||||||||||||||||
| 2284 | case never executed: QEvent::GraphicsSceneHoverLeave:case QEvent::GraphicsSceneHoverLeave:never executed: case QEvent::GraphicsSceneHoverLeave: | 0 | ||||||||||||||||||||||||
| 2285 | case never executed: QEvent::GraphicsSceneHoverMove:case QEvent::GraphicsSceneHoverMove:never executed: case QEvent::GraphicsSceneHoverMove: | 0 | ||||||||||||||||||||||||
| 2286 | { | - | ||||||||||||||||||||||||
| 2287 | QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event); | - | ||||||||||||||||||||||||
| 2288 | d->lastSceneMousePos = hoverEvent->scenePos(); | - | ||||||||||||||||||||||||
| 2289 | d->dispatchHoverEvent(hoverEvent); | - | ||||||||||||||||||||||||
| 2290 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2291 | } | - | ||||||||||||||||||||||||
| 2292 | case never executed: QEvent::Leave:case QEvent::Leave:never executed: case QEvent::Leave: | 0 | ||||||||||||||||||||||||
| 2293 | - | |||||||||||||||||||||||||
| 2294 | d->leaveScene(reinterpret_cast<QWidget *>(event->d)); | - | ||||||||||||||||||||||||
| 2295 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2296 | case never executed: QEvent::GraphicsSceneHelp:case QEvent::GraphicsSceneHelp:never executed: case QEvent::GraphicsSceneHelp: | 0 | ||||||||||||||||||||||||
| 2297 | helpEvent(static_cast<QGraphicsSceneHelpEvent *>(event)); | - | ||||||||||||||||||||||||
| 2298 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2299 | case never executed: QEvent::InputMethod:case QEvent::InputMethod:never executed: case QEvent::InputMethod: | 0 | ||||||||||||||||||||||||
| 2300 | inputMethodEvent(static_cast<QInputMethodEvent *>(event)); | - | ||||||||||||||||||||||||
| 2301 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2302 | case never executed: QEvent::WindowActivate:case QEvent::WindowActivate:never executed: case QEvent::WindowActivate: | 0 | ||||||||||||||||||||||||
| 2303 | if (!d->activationRefCount++
| 0 | ||||||||||||||||||||||||
| 2304 | if (d->lastActivePanel
| 0 | ||||||||||||||||||||||||
| 2305 | - | |||||||||||||||||||||||||
| 2306 | d->setActivePanelHelper(d->lastActivePanel, true); | - | ||||||||||||||||||||||||
| 2307 | } never executed: else if (d->tabFocusFirstend of block
| 0 | ||||||||||||||||||||||||
| 2308 | - | |||||||||||||||||||||||||
| 2309 | - | |||||||||||||||||||||||||
| 2310 | d->setActivePanelHelper(d->tabFocusFirst, true); | - | ||||||||||||||||||||||||
| 2311 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2312 | - | |||||||||||||||||||||||||
| 2313 | QEvent event(QEvent::WindowActivate); | - | ||||||||||||||||||||||||
| 2314 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items())>::type> _container_((items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^const auto items_ = 1)items(); | - | ||||||||||||||||||||||||
| 2315 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items_) { | - | ||||||||||||||||||||||||
| 2316 | if (item->isVisible()
| 0 | ||||||||||||||||||||||||
| 2317 | sendEvent(item, &event); never executed: sendEvent(item, &event); | 0 | ||||||||||||||||||||||||
| 2318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2320 | } | - | ||||||||||||||||||||||||
| 2321 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2322 | case never executed: QEvent::WindowDeactivate:case QEvent::WindowDeactivate:never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||||||||||||||
| 2323 | if (!--d->activationRefCount
| 0 | ||||||||||||||||||||||||
| 2324 | if (d->activePanel
| 0 | ||||||||||||||||||||||||
| 2325 | - | |||||||||||||||||||||||||
| 2326 | - | |||||||||||||||||||||||||
| 2327 | QGraphicsItem *lastActivePanel = d->activePanel; | - | ||||||||||||||||||||||||
| 2328 | d->setActivePanelHelper(0, true); | - | ||||||||||||||||||||||||
| 2329 | d->lastActivePanel = lastActivePanel; | - | ||||||||||||||||||||||||
| 2330 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2331 | - | |||||||||||||||||||||||||
| 2332 | QEvent event(QEvent::WindowDeactivate); | - | ||||||||||||||||||||||||
| 2333 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items())>::type> _container_((items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^const auto items_ = 1)items(); | - | ||||||||||||||||||||||||
| 2334 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items_) { | - | ||||||||||||||||||||||||
| 2335 | if (item->isVisible()
| 0 | ||||||||||||||||||||||||
| 2336 | sendEvent(item, &event); never executed: sendEvent(item, &event); | 0 | ||||||||||||||||||||||||
| 2337 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2338 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2339 | } | - | ||||||||||||||||||||||||
| 2340 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2341 | case never executed: QEvent::ApplicationFontChange:case QEvent::ApplicationFontChange:never executed: {case QEvent::ApplicationFontChange: | 0 | ||||||||||||||||||||||||
| 2342 | - | |||||||||||||||||||||||||
| 2343 | d->resolveFont(); | - | ||||||||||||||||||||||||
| 2344 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2345 | } | - | ||||||||||||||||||||||||
| 2346 | case never executed: QEvent::FontChange:case QEvent::FontChange:never executed: case QEvent::FontChange: | 0 | ||||||||||||||||||||||||
| 2347 | - | |||||||||||||||||||||||||
| 2348 | update(); | - | ||||||||||||||||||||||||
| 2349 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2350 | case never executed: QEvent::ApplicationPaletteChange:case QEvent::ApplicationPaletteChange:never executed: {case QEvent::ApplicationPaletteChange: | 0 | ||||||||||||||||||||||||
| 2351 | - | |||||||||||||||||||||||||
| 2352 | d->resolvePalette(); | - | ||||||||||||||||||||||||
| 2353 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2354 | } | - | ||||||||||||||||||||||||
| 2355 | case never executed: QEvent::PaletteChange:case QEvent::PaletteChange:never executed: case QEvent::PaletteChange: | 0 | ||||||||||||||||||||||||
| 2356 | - | |||||||||||||||||||||||||
| 2357 | update(); | - | ||||||||||||||||||||||||
| 2358 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2359 | case never executed: QEvent::StyleChange:case QEvent::StyleChange:never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||||||||
| 2360 | - | |||||||||||||||||||||||||
| 2361 | - | |||||||||||||||||||||||||
| 2362 | update(); | - | ||||||||||||||||||||||||
| 2363 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2364 | case never executed: QEvent::StyleAnimationUpdate:case QEvent::StyleAnimationUpdate:never executed: case QEvent::StyleAnimationUpdate: | 0 | ||||||||||||||||||||||||
| 2365 | - | |||||||||||||||||||||||||
| 2366 | - | |||||||||||||||||||||||||
| 2367 | update(); | - | ||||||||||||||||||||||||
| 2368 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2369 | case never executed: QEvent::TouchBegin:case QEvent::TouchBegin:never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||||||||
| 2370 | case never executed: QEvent::TouchUpdate:case QEvent::TouchUpdate:never executed: case QEvent::TouchUpdate: | 0 | ||||||||||||||||||||||||
| 2371 | case never executed: QEvent::TouchEnd:case QEvent::TouchEnd:never executed: case QEvent::TouchEnd: | 0 | ||||||||||||||||||||||||
| 2372 | d->touchEventHandler(static_cast<QTouchEvent *>(event)); | - | ||||||||||||||||||||||||
| 2373 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2374 | - | |||||||||||||||||||||||||
| 2375 | case never executed: QEvent::Gesture:case QEvent::Gesture:never executed: case QEvent::Gesture: | 0 | ||||||||||||||||||||||||
| 2376 | case never executed: QEvent::GestureOverride:case QEvent::GestureOverride:never executed: case QEvent::GestureOverride: | 0 | ||||||||||||||||||||||||
| 2377 | d->gestureEventHandler(static_cast<QGestureEvent *>(event)); | - | ||||||||||||||||||||||||
| 2378 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2379 | - | |||||||||||||||||||||||||
| 2380 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 2381 | return never executed: QObject::event(event);return QObject::event(event);never executed: return QObject::event(event); | 0 | ||||||||||||||||||||||||
| 2382 | } | - | ||||||||||||||||||||||||
| 2383 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2384 | } | - | ||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||
| 2386 | - | |||||||||||||||||||||||||
| 2387 | - | |||||||||||||||||||||||||
| 2388 | - | |||||||||||||||||||||||||
| 2389 | - | |||||||||||||||||||||||||
| 2390 | - | |||||||||||||||||||||||||
| 2391 | - | |||||||||||||||||||||||||
| 2392 | bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event) | - | ||||||||||||||||||||||||
| 2393 | { | - | ||||||||||||||||||||||||
| 2394 | if (watched != (static_cast<QApplication *>(QCoreApplication::instance()))) | - | ||||||||||||||||||||||||
| 2395 | return false; | - | ||||||||||||||||||||||||
| 2396 | - | |||||||||||||||||||||||||
| 2397 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 2398 | case QEvent::ApplicationPaletteChange: | - | ||||||||||||||||||||||||
| 2399 | QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); | - | ||||||||||||||||||||||||
| 2400 | break; | - | ||||||||||||||||||||||||
| 2401 | case QEvent::ApplicationFontChange: | - | ||||||||||||||||||||||||
| 2402 | QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange)); | - | ||||||||||||||||||||||||
| 2403 | break; | - | ||||||||||||||||||||||||
| 2404 | default: | - | ||||||||||||||||||||||||
| 2405 | break; | - | ||||||||||||||||||||||||
| 2406 | } | - | ||||||||||||||||||||||||
| 2407 | return false; | - | ||||||||||||||||||||||||
| 2408 | } | - | ||||||||||||||||||||||||
| 2409 | void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) | - | ||||||||||||||||||||||||
| 2410 | { | - | ||||||||||||||||||||||||
| 2411 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2412 | - | |||||||||||||||||||||||||
| 2413 | contextMenuEvent->ignore(); | - | ||||||||||||||||||||||||
| 2414 | - | |||||||||||||||||||||||||
| 2415 | - | |||||||||||||||||||||||||
| 2416 | - | |||||||||||||||||||||||||
| 2417 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->itemsAtPosition(contextMenuEvent->screenPos(), contextMenuEvent->scenePos(), contextMenuEvent->widget()))>::type> _container_((const auto items = d->itemsAtPosition(contextMenuEvent->screenPos(), | - | ||||||||||||||||||||||||
| 2418 | contextMenuEvent->scenePos(), | - | ||||||||||||||||||||||||
| 2419 | contextMenuEvent->widget()))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)()); | - | ||||||||||||||||||||||||
| 2420 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) { | - | ||||||||||||||||||||||||
| 2421 | contextMenuEvent->setPos(item->d_ptr->genericMapFromScene(contextMenuEvent->scenePos(), | - | ||||||||||||||||||||||||
| 2422 | contextMenuEvent->widget())); | - | ||||||||||||||||||||||||
| 2423 | contextMenuEvent->accept(); | - | ||||||||||||||||||||||||
| 2424 | if (!d->sendEvent(item, contextMenuEvent)
| 0 | ||||||||||||||||||||||||
| 2425 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2426 | - | |||||||||||||||||||||||||
| 2427 | if (contextMenuEvent->isAccepted()
| 0 | ||||||||||||||||||||||||
| 2428 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2429 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2430 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2431 | void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event) | - | ||||||||||||||||||||||||
| 2432 | { | - | ||||||||||||||||||||||||
| 2433 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2434 | d->dragDropItem = 0; | - | ||||||||||||||||||||||||
| 2435 | d->lastDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||||||||
| 2436 | event->accept(); | - | ||||||||||||||||||||||||
| 2437 | } | - | ||||||||||||||||||||||||
| 2438 | void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event) | - | ||||||||||||||||||||||||
| 2439 | { | - | ||||||||||||||||||||||||
| 2440 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2441 | event->ignore(); | - | ||||||||||||||||||||||||
| 2442 | - | |||||||||||||||||||||||||
| 2443 | if (!d->mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2444 | - | |||||||||||||||||||||||||
| 2445 | d->clearMouseGrabber(); | - | ||||||||||||||||||||||||
| 2446 | d->mouseGrabberButtonDownPos.clear(); | - | ||||||||||||||||||||||||
| 2447 | d->mouseGrabberButtonDownScenePos.clear(); | - | ||||||||||||||||||||||||
| 2448 | d->mouseGrabberButtonDownScreenPos.clear(); | - | ||||||||||||||||||||||||
| 2449 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2450 | - | |||||||||||||||||||||||||
| 2451 | bool eventDelivered = false; | - | ||||||||||||||||||||||||
| 2452 | - | |||||||||||||||||||||||||
| 2453 | - | |||||||||||||||||||||||||
| 2454 | - | |||||||||||||||||||||||||
| 2455 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->itemsAtPosition(event->screenPos(), event->scenePos(), event->widget()))>::type> _container_((const auto items = d->itemsAtPosition(event->screenPos(), | - | ||||||||||||||||||||||||
| 2456 | event->scenePos(), | - | ||||||||||||||||||||||||
| 2457 | event->widget()))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)()); | - | ||||||||||||||||||||||||
| 2458 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items) { | - | ||||||||||||||||||||||||
| 2459 | if (!item->isEnabled()
| 0 | ||||||||||||||||||||||||
| 2460 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2461 | - | |||||||||||||||||||||||||
| 2462 | if (item != d->dragDropItem
| 0 | ||||||||||||||||||||||||
| 2463 | - | |||||||||||||||||||||||||
| 2464 | - | |||||||||||||||||||||||||
| 2465 | QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter); | - | ||||||||||||||||||||||||
| 2466 | d->cloneDragDropEvent(&dragEnter, event); | - | ||||||||||||||||||||||||
| 2467 | dragEnter.setDropAction(event->proposedAction()); | - | ||||||||||||||||||||||||
| 2468 | d->sendDragDropEvent(item, &dragEnter); | - | ||||||||||||||||||||||||
| 2469 | event->setAccepted(dragEnter.isAccepted()); | - | ||||||||||||||||||||||||
| 2470 | event->setDropAction(dragEnter.dropAction()); | - | ||||||||||||||||||||||||
| 2471 | if (!event->isAccepted()
| 0 | ||||||||||||||||||||||||
| 2472 | - | |||||||||||||||||||||||||
| 2473 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2474 | } | - | ||||||||||||||||||||||||
| 2475 | - | |||||||||||||||||||||||||
| 2476 | d->lastDropAction = event->dropAction(); | - | ||||||||||||||||||||||||
| 2477 | - | |||||||||||||||||||||||||
| 2478 | if (d->dragDropItem
| 0 | ||||||||||||||||||||||||
| 2479 | - | |||||||||||||||||||||||||
| 2480 | - | |||||||||||||||||||||||||
| 2481 | - | |||||||||||||||||||||||||
| 2482 | - | |||||||||||||||||||||||||
| 2483 | QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave); | - | ||||||||||||||||||||||||
| 2484 | d->cloneDragDropEvent(&dragLeave, event); | - | ||||||||||||||||||||||||
| 2485 | d->sendDragDropEvent(d->dragDropItem, &dragLeave); | - | ||||||||||||||||||||||||
| 2486 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2487 | - | |||||||||||||||||||||||||
| 2488 | - | |||||||||||||||||||||||||
| 2489 | d->dragDropItem = item; | - | ||||||||||||||||||||||||
| 2490 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2491 | - | |||||||||||||||||||||||||
| 2492 | - | |||||||||||||||||||||||||
| 2493 | event->setDropAction(d->lastDropAction); | - | ||||||||||||||||||||||||
| 2494 | event->accept(); | - | ||||||||||||||||||||||||
| 2495 | d->sendDragDropEvent(item, event); | - | ||||||||||||||||||||||||
| 2496 | if (event->isAccepted()
| 0 | ||||||||||||||||||||||||
| 2497 | d->lastDropAction = event->dropAction(); never executed: d->lastDropAction = event->dropAction(); | 0 | ||||||||||||||||||||||||
| 2498 | eventDelivered = true; | - | ||||||||||||||||||||||||
| 2499 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2500 | } | - | ||||||||||||||||||||||||
| 2501 | - | |||||||||||||||||||||||||
| 2502 | if (!eventDelivered
| 0 | ||||||||||||||||||||||||
| 2503 | if (d->dragDropItem
| 0 | ||||||||||||||||||||||||
| 2504 | - | |||||||||||||||||||||||||
| 2505 | QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave); | - | ||||||||||||||||||||||||
| 2506 | d->cloneDragDropEvent(&dragLeave, event); | - | ||||||||||||||||||||||||
| 2507 | d->sendDragDropEvent(d->dragDropItem, &dragLeave); | - | ||||||||||||||||||||||||
| 2508 | d->dragDropItem = 0; | - | ||||||||||||||||||||||||
| 2509 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2510 | - | |||||||||||||||||||||||||
| 2511 | event->setDropAction(Qt::IgnoreAction); | - | ||||||||||||||||||||||||
| 2512 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2513 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2514 | void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) | - | ||||||||||||||||||||||||
| 2515 | { | - | ||||||||||||||||||||||||
| 2516 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2517 | if (d->dragDropItem) { | - | ||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||
| 2519 | d->sendDragDropEvent(d->dragDropItem, event); | - | ||||||||||||||||||||||||
| 2520 | d->dragDropItem = 0; | - | ||||||||||||||||||||||||
| 2521 | } | - | ||||||||||||||||||||||||
| 2522 | } | - | ||||||||||||||||||||||||
| 2523 | void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event) | - | ||||||||||||||||||||||||
| 2524 | { | - | ||||||||||||||||||||||||
| 2525 | (void)event;; | - | ||||||||||||||||||||||||
| 2526 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2527 | if (d->dragDropItem) { | - | ||||||||||||||||||||||||
| 2528 | - | |||||||||||||||||||||||||
| 2529 | d->sendDragDropEvent(d->dragDropItem, event); | - | ||||||||||||||||||||||||
| 2530 | d->dragDropItem = 0; | - | ||||||||||||||||||||||||
| 2531 | } | - | ||||||||||||||||||||||||
| 2532 | } | - | ||||||||||||||||||||||||
| 2533 | void QGraphicsScene::focusInEvent(QFocusEvent *focusEvent) | - | ||||||||||||||||||||||||
| 2534 | { | - | ||||||||||||||||||||||||
| 2535 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2536 | - | |||||||||||||||||||||||||
| 2537 | d->hasFocus = true; | - | ||||||||||||||||||||||||
| 2538 | switch (focusEvent->reason()) { | - | ||||||||||||||||||||||||
| 2539 | case Qt::TabFocusReason: | - | ||||||||||||||||||||||||
| 2540 | if (!focusNextPrevChild(true)) | - | ||||||||||||||||||||||||
| 2541 | focusEvent->ignore(); | - | ||||||||||||||||||||||||
| 2542 | break; | - | ||||||||||||||||||||||||
| 2543 | case Qt::BacktabFocusReason: | - | ||||||||||||||||||||||||
| 2544 | if (!focusNextPrevChild(false)) | - | ||||||||||||||||||||||||
| 2545 | focusEvent->ignore(); | - | ||||||||||||||||||||||||
| 2546 | break; | - | ||||||||||||||||||||||||
| 2547 | default: | - | ||||||||||||||||||||||||
| 2548 | if (d->passiveFocusItem) { | - | ||||||||||||||||||||||||
| 2549 | - | |||||||||||||||||||||||||
| 2550 | setFocusItem(d->passiveFocusItem, focusEvent->reason()); | - | ||||||||||||||||||||||||
| 2551 | } | - | ||||||||||||||||||||||||
| 2552 | break; | - | ||||||||||||||||||||||||
| 2553 | } | - | ||||||||||||||||||||||||
| 2554 | } | - | ||||||||||||||||||||||||
| 2555 | void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent) | - | ||||||||||||||||||||||||
| 2556 | { | - | ||||||||||||||||||||||||
| 2557 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2558 | d->hasFocus = false; | - | ||||||||||||||||||||||||
| 2559 | d->passiveFocusItem = d->focusItem; | - | ||||||||||||||||||||||||
| 2560 | setFocusItem(0, focusEvent->reason()); | - | ||||||||||||||||||||||||
| 2561 | - | |||||||||||||||||||||||||
| 2562 | - | |||||||||||||||||||||||||
| 2563 | if (!d->popupWidgets.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2564 | d->removePopup(d->popupWidgets.firstconstFirst()); never executed: d->removePopup(d->popupWidgets.constFirst()); | 0 | ||||||||||||||||||||||||
| 2565 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2566 | void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) | - | ||||||||||||||||||||||||
| 2567 | { | - | ||||||||||||||||||||||||
| 2568 | - | |||||||||||||||||||||||||
| 2569 | - | |||||||||||||||||||||||||
| 2570 | - | |||||||||||||||||||||||||
| 2571 | - | |||||||||||||||||||||||||
| 2572 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2573 | QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(), | - | ||||||||||||||||||||||||
| 2574 | helpEvent->scenePos(), | - | ||||||||||||||||||||||||
| 2575 | helpEvent->widget()); | - | ||||||||||||||||||||||||
| 2576 | QGraphicsItem *toolTipItem = 0; | - | ||||||||||||||||||||||||
| 2577 | for (int i = 0; i < itemsAtPos.size(); ++i) { | - | ||||||||||||||||||||||||
| 2578 | QGraphicsItem *tmp = itemsAtPos.at(i); | - | ||||||||||||||||||||||||
| 2579 | if (tmp->d_func()->isProxyWidget()) { | - | ||||||||||||||||||||||||
| 2580 | - | |||||||||||||||||||||||||
| 2581 | sendEvent(tmp, helpEvent); | - | ||||||||||||||||||||||||
| 2582 | if (helpEvent->isAccepted()) | - | ||||||||||||||||||||||||
| 2583 | return; | - | ||||||||||||||||||||||||
| 2584 | } | - | ||||||||||||||||||||||||
| 2585 | if (!tmp->toolTip().isEmpty()) { | - | ||||||||||||||||||||||||
| 2586 | toolTipItem = tmp; | - | ||||||||||||||||||||||||
| 2587 | break; | - | ||||||||||||||||||||||||
| 2588 | } | - | ||||||||||||||||||||||||
| 2589 | } | - | ||||||||||||||||||||||||
| 2590 | - | |||||||||||||||||||||||||
| 2591 | - | |||||||||||||||||||||||||
| 2592 | QString text; | - | ||||||||||||||||||||||||
| 2593 | QPoint point; | - | ||||||||||||||||||||||||
| 2594 | if (toolTipItem && !toolTipItem->toolTip().isEmpty()) { | - | ||||||||||||||||||||||||
| 2595 | text = toolTipItem->toolTip(); | - | ||||||||||||||||||||||||
| 2596 | point = helpEvent->screenPos(); | - | ||||||||||||||||||||||||
| 2597 | } | - | ||||||||||||||||||||||||
| 2598 | QToolTip::showText(point, text, helpEvent->widget()); | - | ||||||||||||||||||||||||
| 2599 | helpEvent->setAccepted(!text.isEmpty()); | - | ||||||||||||||||||||||||
| 2600 | - | |||||||||||||||||||||||||
| 2601 | } | - | ||||||||||||||||||||||||
| 2602 | - | |||||||||||||||||||||||||
| 2603 | bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const | - | ||||||||||||||||||||||||
| 2604 | { | - | ||||||||||||||||||||||||
| 2605 | return (item->d_ptr->acceptsHover | - | ||||||||||||||||||||||||
| 2606 | || (item->d_ptr->isWidget | - | ||||||||||||||||||||||||
| 2607 | && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) | - | ||||||||||||||||||||||||
| 2608 | && !item->isBlockedByModalPanel(); | - | ||||||||||||||||||||||||
| 2609 | } | - | ||||||||||||||||||||||||
| 2610 | bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent) | - | ||||||||||||||||||||||||
| 2611 | { | - | ||||||||||||||||||||||||
| 2612 | if (allItemsIgnoreHoverEvents
| 0 | ||||||||||||||||||||||||
| 2613 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2614 | - | |||||||||||||||||||||||||
| 2615 | - | |||||||||||||||||||||||||
| 2616 | - | |||||||||||||||||||||||||
| 2617 | if (cachedItemsUnderMouse.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2618 | cachedItemsUnderMouse = itemsAtPosition(hoverEvent->screenPos(), | - | ||||||||||||||||||||||||
| 2619 | hoverEvent->scenePos(), | - | ||||||||||||||||||||||||
| 2620 | hoverEvent->widget()); | - | ||||||||||||||||||||||||
| 2621 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2622 | - | |||||||||||||||||||||||||
| 2623 | QGraphicsItem *item = 0; | - | ||||||||||||||||||||||||
| 2624 | for (int i = 0; i < cachedItemsUnderMouse.size()
| 0 | ||||||||||||||||||||||||
| 2625 | QGraphicsItem *tmp = cachedItemsUnderMouse.at(i); | - | ||||||||||||||||||||||||
| 2626 | if (itemAcceptsHoverEvents_helper(tmp)
| 0 | ||||||||||||||||||||||||
| 2627 | item = tmp; | - | ||||||||||||||||||||||||
| 2628 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2629 | } | - | ||||||||||||||||||||||||
| 2630 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2631 | - | |||||||||||||||||||||||||
| 2632 | - | |||||||||||||||||||||||||
| 2633 | - | |||||||||||||||||||||||||
| 2634 | QGraphicsItem *commonAncestorItem = (item
| 0 | ||||||||||||||||||||||||
| 2635 | while (commonAncestorItem
| 0 | ||||||||||||||||||||||||
| 2636 | commonAncestorItem = commonAncestorItem->parentItem(); never executed: commonAncestorItem = commonAncestorItem->parentItem(); | 0 | ||||||||||||||||||||||||
| 2637 | if (commonAncestorItem
| 0 | ||||||||||||||||||||||||
| 2638 | - | |||||||||||||||||||||||||
| 2639 | - | |||||||||||||||||||||||||
| 2640 | commonAncestorItem = 0; | - | ||||||||||||||||||||||||
| 2641 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2642 | - | |||||||||||||||||||||||||
| 2643 | - | |||||||||||||||||||||||||
| 2644 | int index = commonAncestorItem
| 0 | ||||||||||||||||||||||||
| 2645 | - | |||||||||||||||||||||||||
| 2646 | - | |||||||||||||||||||||||||
| 2647 | for (int i = hoverItems.size() - 1; i > index
| 0 | ||||||||||||||||||||||||
| 2648 | QGraphicsItem *lastItem = hoverItems.takeLast(); | - | ||||||||||||||||||||||||
| 2649 | if (itemAcceptsHoverEvents_helper(lastItem)
| 0 | ||||||||||||||||||||||||
| 2650 | sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent); never executed: sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent); | 0 | ||||||||||||||||||||||||
| 2651 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2652 | - | |||||||||||||||||||||||||
| 2653 | - | |||||||||||||||||||||||||
| 2654 | - | |||||||||||||||||||||||||
| 2655 | QList<QGraphicsItem *> parents; | - | ||||||||||||||||||||||||
| 2656 | QGraphicsItem *parent = item; | - | ||||||||||||||||||||||||
| 2657 | while (parent
| 0 | ||||||||||||||||||||||||
| 2658 | parents.prependappend(parent); | - | ||||||||||||||||||||||||
| 2659 | if (parent->isPanel()
| 0 | ||||||||||||||||||||||||
| 2660 | - | |||||||||||||||||||||||||
| 2661 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2662 | } | - | ||||||||||||||||||||||||
| 2663 | parent = parent->parentItem(); | - | ||||||||||||||||||||||||
| 2664 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2665 | for (int iauto it = 0; i <parents.sizecrbegin(), end = parents.crend(); it != end
| 0 | ||||||||||||||||||||||||
| 2666 | QGraphicsItem *parent = parents.at(i);*it; | - | ||||||||||||||||||||||||
| 2667 | hoverItems << parent; | - | ||||||||||||||||||||||||
| 2668 | if (itemAcceptsHoverEvents_helper(parent)
| 0 | ||||||||||||||||||||||||
| 2669 | sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent); never executed: sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent); | 0 | ||||||||||||||||||||||||
| 2670 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2671 | - | |||||||||||||||||||||||||
| 2672 | - | |||||||||||||||||||||||||
| 2673 | if (item
| 0 | ||||||||||||||||||||||||
| 2674 | && !hoverItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2675 | && item == hoverItems.lastconstLast()
| 0 | ||||||||||||||||||||||||
| 2676 | sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent); | - | ||||||||||||||||||||||||
| 2677 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 2678 | } | - | ||||||||||||||||||||||||
| 2679 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 2680 | } | - | ||||||||||||||||||||||||
| 2681 | - | |||||||||||||||||||||||||
| 2682 | - | |||||||||||||||||||||||||
| 2683 | - | |||||||||||||||||||||||||
| 2684 | - | |||||||||||||||||||||||||
| 2685 | - | |||||||||||||||||||||||||
| 2686 | - | |||||||||||||||||||||||||
| 2687 | - | |||||||||||||||||||||||||
| 2688 | void QGraphicsScenePrivate::leaveScene(QWidget *viewport) | - | ||||||||||||||||||||||||
| 2689 | { | - | ||||||||||||||||||||||||
| 2690 | - | |||||||||||||||||||||||||
| 2691 | QToolTip::hideText(); | - | ||||||||||||||||||||||||
| 2692 | - | |||||||||||||||||||||||||
| 2693 | QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent()); | - | ||||||||||||||||||||||||
| 2694 | - | |||||||||||||||||||||||||
| 2695 | QGraphicsSceneHoverEvent hoverEvent; | - | ||||||||||||||||||||||||
| 2696 | hoverEvent.setWidget(viewport); | - | ||||||||||||||||||||||||
| 2697 | - | |||||||||||||||||||||||||
| 2698 | if (view) { | - | ||||||||||||||||||||||||
| 2699 | QPoint cursorPos = QCursor::pos(); | - | ||||||||||||||||||||||||
| 2700 | hoverEvent.setScenePos(view->mapToScene(viewport->mapFromGlobal(cursorPos))); | - | ||||||||||||||||||||||||
| 2701 | hoverEvent.setLastScenePos(hoverEvent.scenePos()); | - | ||||||||||||||||||||||||
| 2702 | hoverEvent.setScreenPos(cursorPos); | - | ||||||||||||||||||||||||
| 2703 | hoverEvent.setLastScreenPos(hoverEvent.screenPos()); | - | ||||||||||||||||||||||||
| 2704 | } | - | ||||||||||||||||||||||||
| 2705 | - | |||||||||||||||||||||||||
| 2706 | while (!hoverItems.isEmpty()) { | - | ||||||||||||||||||||||||
| 2707 | QGraphicsItem *lastItem = hoverItems.takeLast(); | - | ||||||||||||||||||||||||
| 2708 | if (itemAcceptsHoverEvents_helper(lastItem)) | - | ||||||||||||||||||||||||
| 2709 | sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, &hoverEvent); | - | ||||||||||||||||||||||||
| 2710 | } | - | ||||||||||||||||||||||||
| 2711 | } | - | ||||||||||||||||||||||||
| 2712 | void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent) | - | ||||||||||||||||||||||||
| 2713 | { | - | ||||||||||||||||||||||||
| 2714 | - | |||||||||||||||||||||||||
| 2715 | - | |||||||||||||||||||||||||
| 2716 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2717 | QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2718 | if (!item
| 0 | ||||||||||||||||||||||||
| 2719 | item = focusItem(); never executed: item = focusItem(); | 0 | ||||||||||||||||||||||||
| 2720 | if (item
| 0 | ||||||||||||||||||||||||
| 2721 | QGraphicsItem *p = item; | - | ||||||||||||||||||||||||
| 2722 | do { | - | ||||||||||||||||||||||||
| 2723 | - | |||||||||||||||||||||||||
| 2724 | keyEvent->accept(); | - | ||||||||||||||||||||||||
| 2725 | - | |||||||||||||||||||||||||
| 2726 | - | |||||||||||||||||||||||||
| 2727 | if (p->isBlockedByModalPanel()
| 0 | ||||||||||||||||||||||||
| 2728 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2729 | if (!d->sendEvent(p, keyEvent)
| 0 | ||||||||||||||||||||||||
| 2730 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2731 | } never executed: while (!keyEvent->isAccepted()end of block
| 0 | ||||||||||||||||||||||||
| 2732 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2733 | keyEvent->ignore(); | - | ||||||||||||||||||||||||
| 2734 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2735 | } | - | ||||||||||||||||||||||||
| 2736 | void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent) | - | ||||||||||||||||||||||||
| 2737 | { | - | ||||||||||||||||||||||||
| 2738 | - | |||||||||||||||||||||||||
| 2739 | - | |||||||||||||||||||||||||
| 2740 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2741 | QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2742 | if (!item
| 0 | ||||||||||||||||||||||||
| 2743 | item = focusItem(); never executed: item = focusItem(); | 0 | ||||||||||||||||||||||||
| 2744 | if (item
| 0 | ||||||||||||||||||||||||
| 2745 | QGraphicsItem *p = item; | - | ||||||||||||||||||||||||
| 2746 | do { | - | ||||||||||||||||||||||||
| 2747 | - | |||||||||||||||||||||||||
| 2748 | keyEvent->accept(); | - | ||||||||||||||||||||||||
| 2749 | - | |||||||||||||||||||||||||
| 2750 | - | |||||||||||||||||||||||||
| 2751 | if (p->isBlockedByModalPanel()
| 0 | ||||||||||||||||||||||||
| 2752 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2753 | if (!d->sendEvent(p, keyEvent)
| 0 | ||||||||||||||||||||||||
| 2754 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2755 | } never executed: while (!keyEvent->isAccepted()end of block
| 0 | ||||||||||||||||||||||||
| 2756 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2757 | keyEvent->ignore(); | - | ||||||||||||||||||||||||
| 2758 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2759 | } | - | ||||||||||||||||||||||||
| 2760 | void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 2761 | { | - | ||||||||||||||||||||||||
| 2762 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2763 | if (d->mouseGrabberItems.isEmpty()) { | - | ||||||||||||||||||||||||
| 2764 | - | |||||||||||||||||||||||||
| 2765 | QGraphicsSceneHoverEvent hover; | - | ||||||||||||||||||||||||
| 2766 | _q_hoverFromMouseEvent(&hover, mouseEvent); | - | ||||||||||||||||||||||||
| 2767 | d->dispatchHoverEvent(&hover); | - | ||||||||||||||||||||||||
| 2768 | } | - | ||||||||||||||||||||||||
| 2769 | - | |||||||||||||||||||||||||
| 2770 | d->mousePressEventHandler(mouseEvent); | - | ||||||||||||||||||||||||
| 2771 | } | - | ||||||||||||||||||||||||
| 2772 | void QGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 2773 | { | - | ||||||||||||||||||||||||
| 2774 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2775 | if (d->mouseGrabberItems.isEmpty()) { | - | ||||||||||||||||||||||||
| 2776 | if (mouseEvent->buttons()) | - | ||||||||||||||||||||||||
| 2777 | return; | - | ||||||||||||||||||||||||
| 2778 | QGraphicsSceneHoverEvent hover; | - | ||||||||||||||||||||||||
| 2779 | _q_hoverFromMouseEvent(&hover, mouseEvent); | - | ||||||||||||||||||||||||
| 2780 | mouseEvent->setAccepted(d->dispatchHoverEvent(&hover)); | - | ||||||||||||||||||||||||
| 2781 | return; | - | ||||||||||||||||||||||||
| 2782 | } | - | ||||||||||||||||||||||||
| 2783 | - | |||||||||||||||||||||||||
| 2784 | - | |||||||||||||||||||||||||
| 2785 | d->sendMouseEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 2786 | mouseEvent->accept(); | - | ||||||||||||||||||||||||
| 2787 | } | - | ||||||||||||||||||||||||
| 2788 | void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 2789 | { | - | ||||||||||||||||||||||||
| 2790 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2791 | if (d->mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2792 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 2793 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2794 | } | - | ||||||||||||||||||||||||
| 2795 | - | |||||||||||||||||||||||||
| 2796 | - | |||||||||||||||||||||||||
| 2797 | d->sendMouseEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 2798 | mouseEvent->accept(); | - | ||||||||||||||||||||||||
| 2799 | - | |||||||||||||||||||||||||
| 2800 | - | |||||||||||||||||||||||||
| 2801 | if (!mouseEvent->buttons()
| 0 | ||||||||||||||||||||||||
| 2802 | if (!d->mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 2803 | d->lastMouseGrabberItem = d->mouseGrabberItems.lastconstLast(); | - | ||||||||||||||||||||||||
| 2804 | if (d->lastMouseGrabberItemHasImplicitMouseGrab
| 0 | ||||||||||||||||||||||||
| 2805 | d->mouseGrabberItems.lastconstLast()->ungrabMouse(); never executed: d->mouseGrabberItems.constLast()->ungrabMouse(); | 0 | ||||||||||||||||||||||||
| 2806 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 2807 | d->lastMouseGrabberItem = 0; | - | ||||||||||||||||||||||||
| 2808 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2809 | - | |||||||||||||||||||||||||
| 2810 | - | |||||||||||||||||||||||||
| 2811 | QGraphicsSceneHoverEvent hoverEvent; | - | ||||||||||||||||||||||||
| 2812 | _q_hoverFromMouseEvent(&hoverEvent, mouseEvent); | - | ||||||||||||||||||||||||
| 2813 | d->dispatchHoverEvent(&hoverEvent); | - | ||||||||||||||||||||||||
| 2814 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2815 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2816 | void QGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 2817 | { | - | ||||||||||||||||||||||||
| 2818 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2819 | d->mousePressEventHandler(mouseEvent); | - | ||||||||||||||||||||||||
| 2820 | } | - | ||||||||||||||||||||||||
| 2821 | void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent) | - | ||||||||||||||||||||||||
| 2822 | { | - | ||||||||||||||||||||||||
| 2823 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2824 | const QList<QGraphicsItem *> wheelCandidates = d->itemsAtPosition(wheelEvent->screenPos(), | - | ||||||||||||||||||||||||
| 2825 | wheelEvent->scenePos(), | - | ||||||||||||||||||||||||
| 2826 | wheelEvent->widget()); | - | ||||||||||||||||||||||||
| 2827 | QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.constEnd(); | - | ||||||||||||||||||||||||
| 2828 | while (--
| 0 | ||||||||||||||||||||||||
| 2829 | if (wheelCandidates.first() == *iter
| 0 | ||||||||||||||||||||||||
| 2830 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2831 | d->removePopup(*iter); | - | ||||||||||||||||||||||||
| 2832 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2833 | - | |||||||||||||||||||||||||
| 2834 | - | |||||||||||||||||||||||||
| 2835 | bool hasSetFocus = false; | - | ||||||||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(wheelCandidates)>::type> _container_((wheelCandidates)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||||||||
| 2836 | ++_container_.i, _container_.control ^= 1)for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: wheelCandidates) { | - | ||||||||||||||||||||||||
| 2837 | if (!hasSetFocus
| 0 | ||||||||||||||||||||||||
| 2838 | && ((
| 0 | ||||||||||||||||||||||||
| 2839 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
| 2840 | hasSetFocus = true; | - | ||||||||||||||||||||||||
| 2841 | if (item != focusItem()
| 0 | ||||||||||||||||||||||||
| 2842 | setFocusItem(item, Qt::MouseFocusReason); never executed: setFocusItem(item, Qt::MouseFocusReason); | 0 | ||||||||||||||||||||||||
| 2843 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2844 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2845 | - | |||||||||||||||||||||||||
| 2846 | wheelEvent->setPos(item->d_ptr->genericMapFromScene(wheelEvent->scenePos(), | - | ||||||||||||||||||||||||
| 2847 | wheelEvent->widget())); | - | ||||||||||||||||||||||||
| 2848 | wheelEvent->accept(); | - | ||||||||||||||||||||||||
| 2849 | bool isPanel = item->isPanel(); | - | ||||||||||||||||||||||||
| 2850 | bool ret = d->sendEvent(item, wheelEvent); | - | ||||||||||||||||||||||||
| 2851 | - | |||||||||||||||||||||||||
| 2852 | if (ret
| 0 | ||||||||||||||||||||||||
| 2853 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2854 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2855 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2856 | void QGraphicsScene::inputMethodEvent(QInputMethodEvent *event) | - | ||||||||||||||||||||||||
| 2857 | { | - | ||||||||||||||||||||||||
| 2858 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2859 | if (d->focusItem && (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) | - | ||||||||||||||||||||||||
| 2860 | d->sendEvent(d->focusItem, event); | - | ||||||||||||||||||||||||
| 2861 | } | - | ||||||||||||||||||||||||
| 2862 | void QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect) | - | ||||||||||||||||||||||||
| 2863 | { | - | ||||||||||||||||||||||||
| 2864 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2865 | - | |||||||||||||||||||||||||
| 2866 | if (d->backgroundBrush.style() != Qt::NoBrush) { | - | ||||||||||||||||||||||||
| 2867 | if (d->painterStateProtection) | - | ||||||||||||||||||||||||
| 2868 | painter->save(); | - | ||||||||||||||||||||||||
| 2869 | painter->setBrushOrigin(0, 0); | - | ||||||||||||||||||||||||
| 2870 | painter->fillRect(rect, backgroundBrush()); | - | ||||||||||||||||||||||||
| 2871 | if (d->painterStateProtection) | - | ||||||||||||||||||||||||
| 2872 | painter->restore(); | - | ||||||||||||||||||||||||
| 2873 | } | - | ||||||||||||||||||||||||
| 2874 | } | - | ||||||||||||||||||||||||
| 2875 | void QGraphicsScene::drawForeground(QPainter *painter, const QRectF &rect) | - | ||||||||||||||||||||||||
| 2876 | { | - | ||||||||||||||||||||||||
| 2877 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 2878 | - | |||||||||||||||||||||||||
| 2879 | if (d->foregroundBrush.style() != Qt::NoBrush) { | - | ||||||||||||||||||||||||
| 2880 | if (d->painterStateProtection) | - | ||||||||||||||||||||||||
| 2881 | painter->save(); | - | ||||||||||||||||||||||||
| 2882 | painter->setBrushOrigin(0, 0); | - | ||||||||||||||||||||||||
| 2883 | painter->fillRect(rect, foregroundBrush()); | - | ||||||||||||||||||||||||
| 2884 | if (d->painterStateProtection) | - | ||||||||||||||||||||||||
| 2885 | painter->restore(); | - | ||||||||||||||||||||||||
| 2886 | } | - | ||||||||||||||||||||||||
| 2887 | } | - | ||||||||||||||||||||||||
| 2888 | - | |||||||||||||||||||||||||
| 2889 | static void _q_paintItem(QGraphicsItem *item, QPainter *painter, | - | ||||||||||||||||||||||||
| 2890 | const QStyleOptionGraphicsItem *option, QWidget *widget, | - | ||||||||||||||||||||||||
| 2891 | bool useWindowOpacity, bool painterStateProtection) | - | ||||||||||||||||||||||||
| 2892 | { | - | ||||||||||||||||||||||||
| 2893 | if (!item->isWidget()) { | - | ||||||||||||||||||||||||
| 2894 | item->paint(painter, option, widget); | - | ||||||||||||||||||||||||
| 2895 | return; | - | ||||||||||||||||||||||||
| 2896 | } | - | ||||||||||||||||||||||||
| 2897 | QGraphicsWidget *widgetItem = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
| 2898 | QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(widgetItem); | - | ||||||||||||||||||||||||
| 2899 | const qreal windowOpacity = (proxy && proxy->widget() && useWindowOpacity) | - | ||||||||||||||||||||||||
| 2900 | ? proxy->widget()->windowOpacity() : 1.0; | - | ||||||||||||||||||||||||
| 2901 | const qreal oldPainterOpacity = painter->opacity(); | - | ||||||||||||||||||||||||
| 2902 | - | |||||||||||||||||||||||||
| 2903 | if (qFuzzyIsNull(windowOpacity)) | - | ||||||||||||||||||||||||
| 2904 | return; | - | ||||||||||||||||||||||||
| 2905 | - | |||||||||||||||||||||||||
| 2906 | if (windowOpacity < 1.0) | - | ||||||||||||||||||||||||
| 2907 | painter->setOpacity(oldPainterOpacity * windowOpacity); | - | ||||||||||||||||||||||||
| 2908 | - | |||||||||||||||||||||||||
| 2909 | - | |||||||||||||||||||||||||
| 2910 | Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection(); | - | ||||||||||||||||||||||||
| 2911 | painter->setLayoutDirection(widgetItem->layoutDirection()); | - | ||||||||||||||||||||||||
| 2912 | - | |||||||||||||||||||||||||
| 2913 | if (widgetItem->isWindow() && widgetItem->windowType() != Qt::Popup && widgetItem->windowType() != Qt::ToolTip | - | ||||||||||||||||||||||||
| 2914 | && !(widgetItem->windowFlags() & Qt::FramelessWindowHint)) { | - | ||||||||||||||||||||||||
| 2915 | if (painterStateProtection) | - | ||||||||||||||||||||||||
| 2916 | painter->save(); | - | ||||||||||||||||||||||||
| 2917 | widgetItem->paintWindowFrame(painter, option, widget); | - | ||||||||||||||||||||||||
| 2918 | if (painterStateProtection) | - | ||||||||||||||||||||||||
| 2919 | painter->restore(); | - | ||||||||||||||||||||||||
| 2920 | } else if (widgetItem->autoFillBackground()) { | - | ||||||||||||||||||||||||
| 2921 | painter->fillRect(option->exposedRect, widgetItem->palette().window()); | - | ||||||||||||||||||||||||
| 2922 | } | - | ||||||||||||||||||||||||
| 2923 | - | |||||||||||||||||||||||||
| 2924 | widgetItem->paint(painter, option, widget); | - | ||||||||||||||||||||||||
| 2925 | - | |||||||||||||||||||||||||
| 2926 | - | |||||||||||||||||||||||||
| 2927 | painter->setLayoutDirection(oldLayoutDirection); | - | ||||||||||||||||||||||||
| 2928 | - | |||||||||||||||||||||||||
| 2929 | if (windowOpacity < 1.0) | - | ||||||||||||||||||||||||
| 2930 | painter->setOpacity(oldPainterOpacity); | - | ||||||||||||||||||||||||
| 2931 | } | - | ||||||||||||||||||||||||
| 2932 | - | |||||||||||||||||||||||||
| 2933 | static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &pixmapExposed, | - | ||||||||||||||||||||||||
| 2934 | const QTransform &itemToPixmap, QPainter::RenderHints renderHints, | - | ||||||||||||||||||||||||
| 2935 | const QStyleOptionGraphicsItem *option, bool painterStateProtection) | - | ||||||||||||||||||||||||
| 2936 | { | - | ||||||||||||||||||||||||
| 2937 | QPixmap subPix; | - | ||||||||||||||||||||||||
| 2938 | QPainter pixmapPainter; | - | ||||||||||||||||||||||||
| 2939 | QRect br = pixmapExposed.boundingRect(); | - | ||||||||||||||||||||||||
| 2940 | - | |||||||||||||||||||||||||
| 2941 | - | |||||||||||||||||||||||||
| 2942 | if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) { | - | ||||||||||||||||||||||||
| 2943 | pix->fill(Qt::transparent); | - | ||||||||||||||||||||||||
| 2944 | pixmapPainter.begin(pix); | - | ||||||||||||||||||||||||
| 2945 | } else { | - | ||||||||||||||||||||||||
| 2946 | subPix = QPixmap(br.size()); | - | ||||||||||||||||||||||||
| 2947 | subPix.fill(Qt::transparent); | - | ||||||||||||||||||||||||
| 2948 | pixmapPainter.begin(&subPix); | - | ||||||||||||||||||||||||
| 2949 | pixmapPainter.translate(-br.topLeft()); | - | ||||||||||||||||||||||||
| 2950 | if (!pixmapExposed.isEmpty()) { | - | ||||||||||||||||||||||||
| 2951 | - | |||||||||||||||||||||||||
| 2952 | - | |||||||||||||||||||||||||
| 2953 | pixmapPainter.setClipRegion(pixmapExposed); | - | ||||||||||||||||||||||||
| 2954 | } | - | ||||||||||||||||||||||||
| 2955 | } | - | ||||||||||||||||||||||||
| 2956 | - | |||||||||||||||||||||||||
| 2957 | pixmapPainter.setRenderHints(pixmapPainter.renderHints(), false); | - | ||||||||||||||||||||||||
| 2958 | pixmapPainter.setRenderHints(renderHints, true); | - | ||||||||||||||||||||||||
| 2959 | pixmapPainter.setWorldTransform(itemToPixmap, true); | - | ||||||||||||||||||||||||
| 2960 | - | |||||||||||||||||||||||||
| 2961 | - | |||||||||||||||||||||||||
| 2962 | _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection); | - | ||||||||||||||||||||||||
| 2963 | pixmapPainter.end(); | - | ||||||||||||||||||||||||
| 2964 | - | |||||||||||||||||||||||||
| 2965 | if (!subPix.isNull()) { | - | ||||||||||||||||||||||||
| 2966 | - | |||||||||||||||||||||||||
| 2967 | pixmapPainter.begin(pix); | - | ||||||||||||||||||||||||
| 2968 | pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||||||||
| 2969 | pixmapPainter.setClipRegion(pixmapExposed); | - | ||||||||||||||||||||||||
| 2970 | pixmapPainter.drawPixmap(br.topLeft(), subPix); | - | ||||||||||||||||||||||||
| 2971 | pixmapPainter.end(); | - | ||||||||||||||||||||||||
| 2972 | } | - | ||||||||||||||||||||||||
| 2973 | } | - | ||||||||||||||||||||||||
| 2974 | - | |||||||||||||||||||||||||
| 2975 | - | |||||||||||||||||||||||||
| 2976 | - | |||||||||||||||||||||||||
| 2977 | static inline bool transformIsSimple(const QTransform& transform) | - | ||||||||||||||||||||||||
| 2978 | { | - | ||||||||||||||||||||||||
| 2979 | QTransform::TransformationType type = transform.type(); | - | ||||||||||||||||||||||||
| 2980 | if (type <= QTransform::TxScale) { | - | ||||||||||||||||||||||||
| 2981 | return true; | - | ||||||||||||||||||||||||
| 2982 | } else if (type == QTransform::TxRotate) { | - | ||||||||||||||||||||||||
| 2983 | - | |||||||||||||||||||||||||
| 2984 | qreal m11 = transform.m11(); | - | ||||||||||||||||||||||||
| 2985 | qreal m12 = transform.m12(); | - | ||||||||||||||||||||||||
| 2986 | qreal m21 = transform.m21(); | - | ||||||||||||||||||||||||
| 2987 | qreal m22 = transform.m22(); | - | ||||||||||||||||||||||||
| 2988 | if (m11 == 0.0f && m22 == 0.0f) { | - | ||||||||||||||||||||||||
| 2989 | if (m12 == 1.0f && m21 == -1.0f) | - | ||||||||||||||||||||||||
| 2990 | return true; | - | ||||||||||||||||||||||||
| 2991 | else if (m12 == -1.0f && m21 == 1.0f) | - | ||||||||||||||||||||||||
| 2992 | return true; | - | ||||||||||||||||||||||||
| 2993 | else if (m12 == -1.0f && m21 == -1.0f) | - | ||||||||||||||||||||||||
| 2994 | return true; | - | ||||||||||||||||||||||||
| 2995 | else if (m12 == 1.0f && m21 == 1.0f) | - | ||||||||||||||||||||||||
| 2996 | return true; | - | ||||||||||||||||||||||||
| 2997 | } | - | ||||||||||||||||||||||||
| 2998 | } | - | ||||||||||||||||||||||||
| 2999 | return false; | - | ||||||||||||||||||||||||
| 3000 | } | - | ||||||||||||||||||||||||
| 3001 | - | |||||||||||||||||||||||||
| 3002 | - | |||||||||||||||||||||||||
| 3003 | - | |||||||||||||||||||||||||
| 3004 | - | |||||||||||||||||||||||||
| 3005 | - | |||||||||||||||||||||||||
| 3006 | - | |||||||||||||||||||||||||
| 3007 | void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painter, | - | ||||||||||||||||||||||||
| 3008 | const QStyleOptionGraphicsItem *option, QWidget *widget, | - | ||||||||||||||||||||||||
| 3009 | bool painterStateProtection) | - | ||||||||||||||||||||||||
| 3010 | { | - | ||||||||||||||||||||||||
| 3011 | QGraphicsItemPrivate *itemd = item->d_ptr.data(); | - | ||||||||||||||||||||||||
| 3012 | QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode); | - | ||||||||||||||||||||||||
| 3013 | - | |||||||||||||||||||||||||
| 3014 | - | |||||||||||||||||||||||||
| 3015 | if (cacheMode == QGraphicsItem::NoCache
| 0 | ||||||||||||||||||||||||
| 3016 | - | |||||||||||||||||||||||||
| 3017 | - | |||||||||||||||||||||||||
| 3018 | - | |||||||||||||||||||||||||
| 3019 | ) { | - | ||||||||||||||||||||||||
| 3020 | _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection); | - | ||||||||||||||||||||||||
| 3021 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3022 | } | - | ||||||||||||||||||||||||
| 3023 | - | |||||||||||||||||||||||||
| 3024 | const qreal oldPainterOpacity = painter->opacity(); | - | ||||||||||||||||||||||||
| 3025 | qreal newPainterOpacity = oldPainterOpacity; | - | ||||||||||||||||||||||||
| 3026 | QGraphicsProxyWidget *proxy = item->isWidget()
| 0 | ||||||||||||||||||||||||
| 3027 | if (proxy
| 0 | ||||||||||||||||||||||||
| 3028 | const qreal windowOpacity = proxy->widget()->windowOpacity(); | - | ||||||||||||||||||||||||
| 3029 | if (windowOpacity < 1.0
| 0 | ||||||||||||||||||||||||
| 3030 | newPainterOpacity *= windowOpacity; never executed: newPainterOpacity *= windowOpacity; | 0 | ||||||||||||||||||||||||
| 3031 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3032 | - | |||||||||||||||||||||||||
| 3033 | - | |||||||||||||||||||||||||
| 3034 | QRectF brect = item->boundingRect(); | - | ||||||||||||||||||||||||
| 3035 | QRectF adjustedBrect(brect); | - | ||||||||||||||||||||||||
| 3036 | _q_adjustRect(&adjustedBrect); | - | ||||||||||||||||||||||||
| 3037 | if (adjustedBrect.isEmpty()
| 0 | ||||||||||||||||||||||||
| 3038 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3039 | - | |||||||||||||||||||||||||
| 3040 | - | |||||||||||||||||||||||||
| 3041 | QPixmapCache::Key pixmapKey; | - | ||||||||||||||||||||||||
| 3042 | QPixmap pix; | - | ||||||||||||||||||||||||
| 3043 | bool pixmapFound; | - | ||||||||||||||||||||||||
| 3044 | QGraphicsItemCache *itemCache = itemd->extraItemCache(); | - | ||||||||||||||||||||||||
| 3045 | if (cacheMode == QGraphicsItem::ItemCoordinateCache
| 0 | ||||||||||||||||||||||||
| 3046 | pixmapKey = itemCache->key; | - | ||||||||||||||||||||||||
| 3047 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3048 | pixmapKey = itemCache->deviceData.value(widget).key; | - | ||||||||||||||||||||||||
| 3049 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3050 | - | |||||||||||||||||||||||||
| 3051 | - | |||||||||||||||||||||||||
| 3052 | pixmapFound = QPixmapCache::find(pixmapKey, &pix); | - | ||||||||||||||||||||||||
| 3053 | - | |||||||||||||||||||||||||
| 3054 | - | |||||||||||||||||||||||||
| 3055 | if (cacheMode == QGraphicsItem::ItemCoordinateCache
| 0 | ||||||||||||||||||||||||
| 3056 | QSize pixmapSize; | - | ||||||||||||||||||||||||
| 3057 | bool fixedCacheSize = false; | - | ||||||||||||||||||||||||
| 3058 | QRect br = brect.toAlignedRect(); | - | ||||||||||||||||||||||||
| 3059 | if ((
| 0 | ||||||||||||||||||||||||
| 3060 | pixmapSize = itemCache->fixedSize; | - | ||||||||||||||||||||||||
| 3061 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3062 | pixmapSize = br.size(); | - | ||||||||||||||||||||||||
| 3063 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3064 | - | |||||||||||||||||||||||||
| 3065 | - | |||||||||||||||||||||||||
| 3066 | int adjust = itemCache->fixedSize.isValid()
| 0 | ||||||||||||||||||||||||
| 3067 | QSize adjustSize(adjust*2, adjust*2); | - | ||||||||||||||||||||||||
| 3068 | br.adjust(-adjust, -adjust, adjust, adjust); | - | ||||||||||||||||||||||||
| 3069 | if (pix.isNull()
| 0 | ||||||||||||||||||||||||
| 3070 | pix = QPixmap(pixmapSize + adjustSize); | - | ||||||||||||||||||||||||
| 3071 | itemCache->boundingRect = br; | - | ||||||||||||||||||||||||
| 3072 | itemCache->exposed.clear(); | - | ||||||||||||||||||||||||
| 3073 | itemCache->allExposed = true; | - | ||||||||||||||||||||||||
| 3074 | } never executed: else if (itemCache->boundingRect != brend of block
| 0 | ||||||||||||||||||||||||
| 3075 | itemCache->boundingRect = br; | - | ||||||||||||||||||||||||
| 3076 | itemCache->exposed.clear(); | - | ||||||||||||||||||||||||
| 3077 | itemCache->allExposed = true; | - | ||||||||||||||||||||||||
| 3078 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3079 | - | |||||||||||||||||||||||||
| 3080 | - | |||||||||||||||||||||||||
| 3081 | if (itemCache->allExposed
| 0 | ||||||||||||||||||||||||
| 3082 | - | |||||||||||||||||||||||||
| 3083 | - | |||||||||||||||||||||||||
| 3084 | - | |||||||||||||||||||||||||
| 3085 | if (pixmapFound
| 0 | ||||||||||||||||||||||||
| 3086 | QPixmapCache::remove(pixmapKey); never executed: QPixmapCache::remove(pixmapKey); | 0 | ||||||||||||||||||||||||
| 3087 | - | |||||||||||||||||||||||||
| 3088 | - | |||||||||||||||||||||||||
| 3089 | QTransform itemToPixmap; | - | ||||||||||||||||||||||||
| 3090 | if (fixedCacheSize
| 0 | ||||||||||||||||||||||||
| 3091 | const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height()); | - | ||||||||||||||||||||||||
| 3092 | itemToPixmap.scale(scale.x(), scale.y()); | - | ||||||||||||||||||||||||
| 3093 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3094 | itemToPixmap.translate(-br.x(), -br.y()); | - | ||||||||||||||||||||||||
| 3095 | - | |||||||||||||||||||||||||
| 3096 | - | |||||||||||||||||||||||||
| 3097 | - | |||||||||||||||||||||||||
| 3098 | styleOptionTmp = *option; | - | ||||||||||||||||||||||||
| 3099 | QRegion pixmapExposed; | - | ||||||||||||||||||||||||
| 3100 | QRectF exposedRect; | - | ||||||||||||||||||||||||
| 3101 | if (!itemCache->allExposed
| 0 | ||||||||||||||||||||||||
| 3102 | for (int i = 0; i < itemCache->exposed.size()
| 0 | ||||||||||||||||||||||||
| 3103 | QRectF r = itemCache->exposed.at(i); | - | ||||||||||||||||||||||||
| 3104 | exposedRect |= r; | - | ||||||||||||||||||||||||
| 3105 | pixmapExposed += itemToPixmap.mapRect(r).toAlignedRect(); | - | ||||||||||||||||||||||||
| 3106 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3107 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3108 | exposedRect = brect; | - | ||||||||||||||||||||||||
| 3109 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3110 | styleOptionTmp.exposedRect = exposedRect; | - | ||||||||||||||||||||||||
| 3111 | - | |||||||||||||||||||||||||
| 3112 | - | |||||||||||||||||||||||||
| 3113 | _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(), | - | ||||||||||||||||||||||||
| 3114 | &styleOptionTmp, painterStateProtection); | - | ||||||||||||||||||||||||
| 3115 | - | |||||||||||||||||||||||||
| 3116 | - | |||||||||||||||||||||||||
| 3117 | itemCache->key = QPixmapCache::insert(pix); | - | ||||||||||||||||||||||||
| 3118 | - | |||||||||||||||||||||||||
| 3119 | - | |||||||||||||||||||||||||
| 3120 | itemCache->allExposed = false; | - | ||||||||||||||||||||||||
| 3121 | itemCache->exposed.clear(); | - | ||||||||||||||||||||||||
| 3122 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3123 | - | |||||||||||||||||||||||||
| 3124 | - | |||||||||||||||||||||||||
| 3125 | - | |||||||||||||||||||||||||
| 3126 | - | |||||||||||||||||||||||||
| 3127 | if (newPainterOpacity != oldPainterOpacity
| 0 | ||||||||||||||||||||||||
| 3128 | painter->setOpacity(newPainterOpacity); | - | ||||||||||||||||||||||||
| 3129 | painter->drawPixmap(br.topLeft(), pix); | - | ||||||||||||||||||||||||
| 3130 | painter->setOpacity(oldPainterOpacity); | - | ||||||||||||||||||||||||
| 3131 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3132 | painter->drawPixmap(br.topLeft(), pix); | - | ||||||||||||||||||||||||
| 3133 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3134 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3135 | } | - | ||||||||||||||||||||||||
| 3136 | - | |||||||||||||||||||||||||
| 3137 | - | |||||||||||||||||||||||||
| 3138 | if (cacheMode == QGraphicsItem::DeviceCoordinateCache
| 0 | ||||||||||||||||||||||||
| 3139 | - | |||||||||||||||||||||||||
| 3140 | QRectF deviceBounds = painter->worldTransform().mapRect(brect); | - | ||||||||||||||||||||||||
| 3141 | QRect deviceRect = deviceBounds.toRect().adjusted(-1, -1, 1, 1); | - | ||||||||||||||||||||||||
| 3142 | if (deviceRect.isEmpty()
| 0 | ||||||||||||||||||||||||
| 3143 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3144 | QRect viewRect = widget
| 0 | ||||||||||||||||||||||||
| 3145 | if (widget
| 0 | ||||||||||||||||||||||||
| 3146 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3147 | - | |||||||||||||||||||||||||
| 3148 | - | |||||||||||||||||||||||||
| 3149 | - | |||||||||||||||||||||||||
| 3150 | QSize maximumCacheSize = | - | ||||||||||||||||||||||||
| 3151 | itemd->extra(QGraphicsItemPrivate::ExtraMaxDeviceCoordCacheSize).toSize(); | - | ||||||||||||||||||||||||
| 3152 | if (!maximumCacheSize.isEmpty()
| 0 | ||||||||||||||||||||||||
| 3153 | && (deviceRect.width() > maximumCacheSize.width()
| 0 | ||||||||||||||||||||||||
| 3154 | || deviceRect.height() > maximumCacheSize.height()
| 0 | ||||||||||||||||||||||||
| 3155 | _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, | - | ||||||||||||||||||||||||
| 3156 | oldPainterOpacity != newPainterOpacity, painterStateProtection); | - | ||||||||||||||||||||||||
| 3157 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3158 | } | - | ||||||||||||||||||||||||
| 3159 | - | |||||||||||||||||||||||||
| 3160 | - | |||||||||||||||||||||||||
| 3161 | - | |||||||||||||||||||||||||
| 3162 | - | |||||||||||||||||||||||||
| 3163 | bool pixModified = false; | - | ||||||||||||||||||||||||
| 3164 | QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget]; | - | ||||||||||||||||||||||||
| 3165 | bool invertable = true; | - | ||||||||||||||||||||||||
| 3166 | QTransform diff = deviceData->lastTransform.inverted(&invertable); | - | ||||||||||||||||||||||||
| 3167 | if (invertable
| 0 | ||||||||||||||||||||||||
| 3168 | diff *= painter->worldTransform(); never executed: diff *= painter->worldTransform(); | 0 | ||||||||||||||||||||||||
| 3169 | deviceData->lastTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 3170 | bool allowPartialCacheExposure = false; | - | ||||||||||||||||||||||||
| 3171 | bool simpleTransform = invertable
| 0 | ||||||||||||||||||||||||
| 3172 | && transformIsSimple(painter->worldTransform())
| 0 | ||||||||||||||||||||||||
| 3173 | if (!simpleTransform
| 0 | ||||||||||||||||||||||||
| 3174 | pixModified = true; | - | ||||||||||||||||||||||||
| 3175 | itemCache->allExposed = true; | - | ||||||||||||||||||||||||
| 3176 | itemCache->exposed.clear(); | - | ||||||||||||||||||||||||
| 3177 | deviceData->cacheIndent = QPoint(); | - | ||||||||||||||||||||||||
| 3178 | pix = QPixmap(); | - | ||||||||||||||||||||||||
| 3179 | } never executed: else if (!viewRect.isNull()end of block
| 0 | ||||||||||||||||||||||||
| 3180 | allowPartialCacheExposure = deviceData->cacheIndent != QPoint(); | - | ||||||||||||||||||||||||
| 3181 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3182 | - | |||||||||||||||||||||||||
| 3183 | - | |||||||||||||||||||||||||
| 3184 | - | |||||||||||||||||||||||||
| 3185 | if (!allowPartialCacheExposure
| 0 | ||||||||||||||||||||||||
| 3186 | allowPartialCacheExposure = (
| 0 | ||||||||||||||||||||||||
| 3187 | || (
| 0 | ||||||||||||||||||||||||
| 3188 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3189 | - | |||||||||||||||||||||||||
| 3190 | QRegion scrollExposure; | - | ||||||||||||||||||||||||
| 3191 | if (allowPartialCacheExposure
| 0 | ||||||||||||||||||||||||
| 3192 | - | |||||||||||||||||||||||||
| 3193 | - | |||||||||||||||||||||||||
| 3194 | - | |||||||||||||||||||||||||
| 3195 | - | |||||||||||||||||||||||||
| 3196 | int dx = deviceRect.left() < viewRect.left()
| 0 | ||||||||||||||||||||||||
| 3197 | int dy = deviceRect.top() < viewRect.top()
| 0 | ||||||||||||||||||||||||
| 3198 | QPoint newCacheIndent(dx, dy); | - | ||||||||||||||||||||||||
| 3199 | deviceRect &= viewRect; | - | ||||||||||||||||||||||||
| 3200 | - | |||||||||||||||||||||||||
| 3201 | if (pix.isNull()
| 0 | ||||||||||||||||||||||||
| 3202 | deviceData->cacheIndent = QPoint(); | - | ||||||||||||||||||||||||
| 3203 | itemCache->allExposed = true; | - | ||||||||||||||||||||||||
| 3204 | itemCache->exposed.clear(); | - | ||||||||||||||||||||||||
| 3205 | pixModified = true; | - | ||||||||||||||||||||||||
| 3206 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3207 | - | |||||||||||||||||||||||||
| 3208 | - | |||||||||||||||||||||||||
| 3209 | - | |||||||||||||||||||||||||
| 3210 | if (newCacheIndent != deviceData->cacheIndent
| 0 | ||||||||||||||||||||||||
| 3211 | QPoint diff = newCacheIndent - deviceData->cacheIndent; | - | ||||||||||||||||||||||||
| 3212 | QPixmap newPix(deviceRect.size()); | - | ||||||||||||||||||||||||
| 3213 | - | |||||||||||||||||||||||||
| 3214 | - | |||||||||||||||||||||||||
| 3215 | newPix.fill(Qt::transparent); | - | ||||||||||||||||||||||||
| 3216 | if (!pix.isNull()
| 0 | ||||||||||||||||||||||||
| 3217 | QPainter newPixPainter(&newPix); | - | ||||||||||||||||||||||||
| 3218 | newPixPainter.drawPixmap(-diff, pix); | - | ||||||||||||||||||||||||
| 3219 | newPixPainter.end(); | - | ||||||||||||||||||||||||
| 3220 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3221 | QRegion exposed; | - | ||||||||||||||||||||||||
| 3222 | exposed += newPix.rect(); | - | ||||||||||||||||||||||||
| 3223 | if (!pix.isNull()
| 0 | ||||||||||||||||||||||||
| 3224 | exposed -= QRect(-diff, pix.size()); never executed: exposed -= QRect(-diff, pix.size()); | 0 | ||||||||||||||||||||||||
| 3225 | scrollExposure = exposed; | - | ||||||||||||||||||||||||
| 3226 | - | |||||||||||||||||||||||||
| 3227 | pix = newPix; | - | ||||||||||||||||||||||||
| 3228 | pixModified = true; | - | ||||||||||||||||||||||||
| 3229 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3230 | deviceData->cacheIndent = newCacheIndent; | - | ||||||||||||||||||||||||
| 3231 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3232 | - | |||||||||||||||||||||||||
| 3233 | deviceData->cacheIndent = QPoint(); | - | ||||||||||||||||||||||||
| 3234 | - | |||||||||||||||||||||||||
| 3235 | - | |||||||||||||||||||||||||
| 3236 | if (deviceRect.size() != pix.size()
| 0 | ||||||||||||||||||||||||
| 3237 | - | |||||||||||||||||||||||||
| 3238 | pix = QPixmap(deviceRect.size()); | - | ||||||||||||||||||||||||
| 3239 | pixModified = true; | - | ||||||||||||||||||||||||
| 3240 | itemCache->allExposed = true; | - | ||||||||||||||||||||||||
| 3241 | itemCache->exposed.clear(); | - | ||||||||||||||||||||||||
| 3242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3243 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3244 | - | |||||||||||||||||||||||||
| 3245 | - | |||||||||||||||||||||||||
| 3246 | if (itemCache->allExposed
| 0 | ||||||||||||||||||||||||
| 3247 | - | |||||||||||||||||||||||||
| 3248 | - | |||||||||||||||||||||||||
| 3249 | if (pixmapFound
| 0 | ||||||||||||||||||||||||
| 3250 | QPixmapCache::remove(pixmapKey); never executed: QPixmapCache::remove(pixmapKey); | 0 | ||||||||||||||||||||||||
| 3251 | - | |||||||||||||||||||||||||
| 3252 | - | |||||||||||||||||||||||||
| 3253 | QPointF p = deviceRect.topLeft(); | - | ||||||||||||||||||||||||
| 3254 | QTransform itemToPixmap = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 3255 | if (!p.isNull()
| 0 | ||||||||||||||||||||||||
| 3256 | itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y()); never executed: itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y()); | 0 | ||||||||||||||||||||||||
| 3257 | - | |||||||||||||||||||||||||
| 3258 | - | |||||||||||||||||||||||||
| 3259 | QRegion pixmapExposed = scrollExposure; | - | ||||||||||||||||||||||||
| 3260 | if (!itemCache->allExposed
| 0 | ||||||||||||||||||||||||
| 3261 | const QVector<QRectF> &exposed = itemCache->exposed; | - | ||||||||||||||||||||||||
| 3262 | for (int i = 0; i < exposed.size()
| 0 | ||||||||||||||||||||||||
| 3263 | 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 | ||||||||||||||||||||||||
| 3264 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3265 | - | |||||||||||||||||||||||||
| 3266 | - | |||||||||||||||||||||||||
| 3267 | QRectF br; | - | ||||||||||||||||||||||||
| 3268 | if (itemCache->allExposed
| 0 | ||||||||||||||||||||||||
| 3269 | br = item->boundingRect(); | - | ||||||||||||||||||||||||
| 3270 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3271 | const QVector<QRectF> &exposed = itemCache->exposed; | - | ||||||||||||||||||||||||
| 3272 | for (int i = 0; i < exposed.size()
| 0 | ||||||||||||||||||||||||
| 3273 | br |= exposed.at(i); never executed: br |= exposed.at(i); | 0 | ||||||||||||||||||||||||
| 3274 | QTransform pixmapToItem = itemToPixmap.inverted(); | - | ||||||||||||||||||||||||
| 3275 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(scrollExposure.const auto rects ())>::type> _container_((= scrollExposure.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||||||||
| 3276 | for (const QRect &r = *_container_.i; _container_.control; _container_.control = 0: rects) | - | ||||||||||||||||||||||||
| 3277 | br |= pixmapToItem.mapRect(r); never executed: br |= pixmapToItem.mapRect(r); | 0 | ||||||||||||||||||||||||
| 3278 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3279 | styleOptionTmp = *option; | - | ||||||||||||||||||||||||
| 3280 | styleOptionTmp.exposedRect = br.adjusted(-1, -1, 1, 1); | - | ||||||||||||||||||||||||
| 3281 | - | |||||||||||||||||||||||||
| 3282 | - | |||||||||||||||||||||||||
| 3283 | _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(), | - | ||||||||||||||||||||||||
| 3284 | &styleOptionTmp, painterStateProtection); | - | ||||||||||||||||||||||||
| 3285 | - | |||||||||||||||||||||||||
| 3286 | - | |||||||||||||||||||||||||
| 3287 | pixModified = true; | - | ||||||||||||||||||||||||
| 3288 | itemCache->allExposed = false; | - | ||||||||||||||||||||||||
| 3289 | itemCache->exposed.clear(); | - | ||||||||||||||||||||||||
| 3290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3291 | - | |||||||||||||||||||||||||
| 3292 | if (pixModified
| 0 | ||||||||||||||||||||||||
| 3293 | - | |||||||||||||||||||||||||
| 3294 | deviceData->key = QPixmapCache::insert(pix); | - | ||||||||||||||||||||||||
| 3295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3296 | - | |||||||||||||||||||||||||
| 3297 | - | |||||||||||||||||||||||||
| 3298 | - | |||||||||||||||||||||||||
| 3299 | QTransform restoreTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 3300 | painter->setWorldTransform(QTransform()); | - | ||||||||||||||||||||||||
| 3301 | if (newPainterOpacity != oldPainterOpacity
| 0 | ||||||||||||||||||||||||
| 3302 | painter->setOpacity(newPainterOpacity); | - | ||||||||||||||||||||||||
| 3303 | painter->drawPixmap(deviceRect.topLeft(), pix); | - | ||||||||||||||||||||||||
| 3304 | painter->setOpacity(oldPainterOpacity); | - | ||||||||||||||||||||||||
| 3305 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 3306 | painter->drawPixmap(deviceRect.topLeft(), pix); | - | ||||||||||||||||||||||||
| 3307 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3308 | painter->setWorldTransform(restoreTransform); | - | ||||||||||||||||||||||||
| 3309 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3310 | } | - | ||||||||||||||||||||||||
| 3311 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3312 | - | |||||||||||||||||||||||||
| 3313 | void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const viewTransform, | - | ||||||||||||||||||||||||
| 3314 | QRegion *exposedRegion, QWidget *widget) | - | ||||||||||||||||||||||||
| 3315 | { | - | ||||||||||||||||||||||||
| 3316 | - | |||||||||||||||||||||||||
| 3317 | if (!unpolishedItems.isEmpty()) | - | ||||||||||||||||||||||||
| 3318 | _q_polishItems(); | - | ||||||||||||||||||||||||
| 3319 | - | |||||||||||||||||||||||||
| 3320 | updateAll = false; | - | ||||||||||||||||||||||||
| 3321 | QRectF exposedSceneRect; | - | ||||||||||||||||||||||||
| 3322 | if (exposedRegion && indexMethod != QGraphicsScene::NoIndex) { | - | ||||||||||||||||||||||||
| 3323 | exposedSceneRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1); | - | ||||||||||||||||||||||||
| 3324 | if (viewTransform) | - | ||||||||||||||||||||||||
| 3325 | exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect); | - | ||||||||||||||||||||||||
| 3326 | } | - | ||||||||||||||||||||||||
| 3327 | const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder); | - | ||||||||||||||||||||||||
| 3328 | for (int i = 0; i < tli.size(); ++i) | - | ||||||||||||||||||||||||
| 3329 | drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget); | - | ||||||||||||||||||||||||
| 3330 | } | - | ||||||||||||||||||||||||
| 3331 | - | |||||||||||||||||||||||||
| 3332 | void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, | - | ||||||||||||||||||||||||
| 3333 | const QTransform *const viewTransform, | - | ||||||||||||||||||||||||
| 3334 | QRegion *exposedRegion, QWidget *widget, | - | ||||||||||||||||||||||||
| 3335 | qreal parentOpacity, const QTransform *const effectTransform) | - | ||||||||||||||||||||||||
| 3336 | { | - | ||||||||||||||||||||||||
| 3337 | ((!(item)) ? qt_assert("item",__FILE__,46994723) : qt_noop()); | - | ||||||||||||||||||||||||
| 3338 | - | |||||||||||||||||||||||||
| 3339 | if (!item->d_ptr->visible) | - | ||||||||||||||||||||||||
| 3340 | return; | - | ||||||||||||||||||||||||
| 3341 | - | |||||||||||||||||||||||||
| 3342 | const bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents); | - | ||||||||||||||||||||||||
| 3343 | const bool itemHasChildren = !item->d_ptr->children.isEmpty(); | - | ||||||||||||||||||||||||
| 3344 | if (!itemHasContents && !itemHasChildren) | - | ||||||||||||||||||||||||
| 3345 | return; | - | ||||||||||||||||||||||||
| 3346 | - | |||||||||||||||||||||||||
| 3347 | const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity); | - | ||||||||||||||||||||||||
| 3348 | const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity); | - | ||||||||||||||||||||||||
| 3349 | if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity())) | - | ||||||||||||||||||||||||
| 3350 | return; | - | ||||||||||||||||||||||||
| 3351 | - | |||||||||||||||||||||||||
| 3352 | QTransform transform(Qt::Uninitialized); | - | ||||||||||||||||||||||||
| 3353 | QTransform *transformPtr = 0; | - | ||||||||||||||||||||||||
| 3354 | bool translateOnlyTransform = false; | - | ||||||||||||||||||||||||
| 3355 | bool wasDirtyParentSceneTransform = false; | - | ||||||||||||||||||||||||
| 3356 | const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable(); | - | ||||||||||||||||||||||||
| 3357 | if (itemIsUntransformable) { | - | ||||||||||||||||||||||||
| 3358 | transform = item->deviceTransform(viewTransform ? *viewTransform : QTransform()); | - | ||||||||||||||||||||||||
| 3359 | transformPtr = &transform; | - | ||||||||||||||||||||||||
| 3360 | } else if (item->d_ptr->dirtySceneTransform) { | - | ||||||||||||||||||||||||
| 3361 | item->d_ptr->updateSceneTransformFromParent(); | - | ||||||||||||||||||||||||
| 3362 | ((!(!item->d_ptr->dirtySceneTransform)) ? qt_assert("!item->d_ptr->dirtySceneTransform",__FILE__,47394763) : qt_noop()); | - | ||||||||||||||||||||||||
| 3363 | wasDirtyParentSceneTransform = true; | - | ||||||||||||||||||||||||
| 3364 | } | - | ||||||||||||||||||||||||
| 3365 | - | |||||||||||||||||||||||||
| 3366 | const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape | - | ||||||||||||||||||||||||
| 3367 | || item->d_ptr->flags & QGraphicsItem::ItemContainsChildrenInShape); | - | ||||||||||||||||||||||||
| 3368 | bool drawItem = itemHasContents && !itemIsFullyTransparent; | - | ||||||||||||||||||||||||
| 3369 | if (drawItem || minimumRenderSize > 0.0) { | - | ||||||||||||||||||||||||
| 3370 | const QRectF brect = adjustedItemEffectiveBoundingRect(item); | - | ||||||||||||||||||||||||
| 3371 | if (!transformPtr) { ((!(!itemIsUntransformable)) ? qt_assert("!itemIsUntransformable",__FILE__,47484772) : qt_noop()); if (viewTransform) { transform = item->d_ptr->sceneTransform; transform *= *viewTransform; transformPtr = &transform; } else { transformPtr = &item->d_ptr->sceneTransform; translateOnlyTransform = item->d_ptr->sceneTransformTranslateOnly; } } | - | ||||||||||||||||||||||||
| 3372 | QRectF preciseViewBoundingRect = translateOnlyTransform ? brect.translated(transformPtr->dx(), transformPtr->dy()) | - | ||||||||||||||||||||||||
| 3373 | : transformPtr->mapRect(brect); | - | ||||||||||||||||||||||||
| 3374 | - | |||||||||||||||||||||||||
| 3375 | bool itemIsTooSmallToRender = false; | - | ||||||||||||||||||||||||
| 3376 | if (minimumRenderSize > 0.0 | - | ||||||||||||||||||||||||
| 3377 | && (preciseViewBoundingRect.width() < minimumRenderSize | - | ||||||||||||||||||||||||
| 3378 | || preciseViewBoundingRect.height() < minimumRenderSize)) { | - | ||||||||||||||||||||||||
| 3379 | itemIsTooSmallToRender = true; | - | ||||||||||||||||||||||||
| 3380 | drawItem = false; | - | ||||||||||||||||||||||||
| 3381 | } | - | ||||||||||||||||||||||||
| 3382 | - | |||||||||||||||||||||||||
| 3383 | bool itemIsOutsideVisibleRect = false; | - | ||||||||||||||||||||||||
| 3384 | if (drawItem) { | - | ||||||||||||||||||||||||
| 3385 | QRect viewBoundingRect = preciseViewBoundingRect.toAlignedRect(); | - | ||||||||||||||||||||||||
| 3386 | viewBoundingRect.adjust(-int(rectAdjust), -int(rectAdjust), rectAdjust, rectAdjust); | - | ||||||||||||||||||||||||
| 3387 | if (widget) | - | ||||||||||||||||||||||||
| 3388 | item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect); | - | ||||||||||||||||||||||||
| 3389 | drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect) | - | ||||||||||||||||||||||||
| 3390 | : !viewBoundingRect.normalized().isEmpty(); | - | ||||||||||||||||||||||||
| 3391 | itemIsOutsideVisibleRect = !drawItem; | - | ||||||||||||||||||||||||
| 3392 | } | - | ||||||||||||||||||||||||
| 3393 | - | |||||||||||||||||||||||||
| 3394 | if (itemIsTooSmallToRender || itemIsOutsideVisibleRect) { | - | ||||||||||||||||||||||||
| 3395 | - | |||||||||||||||||||||||||
| 3396 | - | |||||||||||||||||||||||||
| 3397 | - | |||||||||||||||||||||||||
| 3398 | - | |||||||||||||||||||||||||
| 3399 | - | |||||||||||||||||||||||||
| 3400 | if (!itemHasChildren) | - | ||||||||||||||||||||||||
| 3401 | return; | - | ||||||||||||||||||||||||
| 3402 | if (itemClipsChildrenToShape) { | - | ||||||||||||||||||||||||
| 3403 | if (wasDirtyParentSceneTransform) | - | ||||||||||||||||||||||||
| 3404 | item->d_ptr->invalidateChildrenSceneTransform(); | - | ||||||||||||||||||||||||
| 3405 | return; | - | ||||||||||||||||||||||||
| 3406 | } | - | ||||||||||||||||||||||||
| 3407 | } | - | ||||||||||||||||||||||||
| 3408 | } | - | ||||||||||||||||||||||||
| 3409 | - | |||||||||||||||||||||||||
| 3410 | if (itemHasChildren && itemClipsChildrenToShape) | - | ||||||||||||||||||||||||
| 3411 | if (!transformPtr) { ((!(!itemIsUntransformable)) ? qt_assert("!itemIsUntransformable",__FILE__,47884812) : qt_noop()); if (viewTransform) { transform = item->d_ptr->sceneTransform; transform *= *viewTransform; transformPtr = &transform; } else { transformPtr = &item->d_ptr->sceneTransform; translateOnlyTransform = item->d_ptr->sceneTransformTranslateOnly; } }; | - | ||||||||||||||||||||||||
| 3412 | - | |||||||||||||||||||||||||
| 3413 | - | |||||||||||||||||||||||||
| 3414 | if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) { | - | ||||||||||||||||||||||||
| 3415 | if (!transformPtr) { ((!(!itemIsUntransformable)) ? qt_assert("!itemIsUntransformable",__FILE__,47924816) : qt_noop()); if (viewTransform) { transform = item->d_ptr->sceneTransform; transform *= *viewTransform; transformPtr = &transform; } else { transformPtr = &item->d_ptr->sceneTransform; translateOnlyTransform = item->d_ptr->sceneTransformTranslateOnly; } }; | - | ||||||||||||||||||||||||
| 3416 | QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp, | - | ||||||||||||||||||||||||
| 3417 | painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent); | - | ||||||||||||||||||||||||
| 3418 | QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source; | - | ||||||||||||||||||||||||
| 3419 | QGraphicsItemEffectSourcePrivate *sourced = static_cast<QGraphicsItemEffectSourcePrivate *> | - | ||||||||||||||||||||||||
| 3420 | (source->d_func()); | - | ||||||||||||||||||||||||
| 3421 | sourced->info = &info; | - | ||||||||||||||||||||||||
| 3422 | const QTransform restoreTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 3423 | if (effectTransform) | - | ||||||||||||||||||||||||
| 3424 | painter->setWorldTransform(*transformPtr * *effectTransform); | - | ||||||||||||||||||||||||
| 3425 | else | - | ||||||||||||||||||||||||
| 3426 | painter->setWorldTransform(*transformPtr); | - | ||||||||||||||||||||||||
| 3427 | painter->setOpacity(opacity); | - | ||||||||||||||||||||||||
| 3428 | - | |||||||||||||||||||||||||
| 3429 | if (sourced->currentCachedSystem() != Qt::LogicalCoordinates | - | ||||||||||||||||||||||||
| 3430 | && sourced->lastEffectTransform != painter->worldTransform()) | - | ||||||||||||||||||||||||
| 3431 | { | - | ||||||||||||||||||||||||
| 3432 | if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate | - | ||||||||||||||||||||||||
| 3433 | && painter->worldTransform().type() <= QTransform::TxTranslate) | - | ||||||||||||||||||||||||
| 3434 | { | - | ||||||||||||||||||||||||
| 3435 | QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates); | - | ||||||||||||||||||||||||
| 3436 | QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect); | - | ||||||||||||||||||||||||
| 3437 | - | |||||||||||||||||||||||||
| 3438 | sourced->setCachedOffset(effectRect.topLeft()); | - | ||||||||||||||||||||||||
| 3439 | } else { | - | ||||||||||||||||||||||||
| 3440 | sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged); | - | ||||||||||||||||||||||||
| 3441 | } | - | ||||||||||||||||||||||||
| 3442 | - | |||||||||||||||||||||||||
| 3443 | sourced->lastEffectTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 3444 | } | - | ||||||||||||||||||||||||
| 3445 | - | |||||||||||||||||||||||||
| 3446 | item->d_ptr->graphicsEffect->draw(painter); | - | ||||||||||||||||||||||||
| 3447 | painter->setWorldTransform(restoreTransform); | - | ||||||||||||||||||||||||
| 3448 | sourced->info = 0; | - | ||||||||||||||||||||||||
| 3449 | } else | - | ||||||||||||||||||||||||
| 3450 | - | |||||||||||||||||||||||||
| 3451 | { | - | ||||||||||||||||||||||||
| 3452 | draw(item, painter, viewTransform, transformPtr, exposedRegion, widget, opacity, | - | ||||||||||||||||||||||||
| 3453 | effectTransform, wasDirtyParentSceneTransform, drawItem); | - | ||||||||||||||||||||||||
| 3454 | } | - | ||||||||||||||||||||||||
| 3455 | } | - | ||||||||||||||||||||||||
| 3456 | - | |||||||||||||||||||||||||
| 3457 | static inline void setClip(QPainter *painter, QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 3458 | { | - | ||||||||||||||||||||||||
| 3459 | painter->save(); | - | ||||||||||||||||||||||||
| 3460 | QRectF clipRect; | - | ||||||||||||||||||||||||
| 3461 | const QPainterPath clipPath(item->shape()); | - | ||||||||||||||||||||||||
| 3462 | if (QPathClipper::pathToRect(clipPath, &clipRect)) | - | ||||||||||||||||||||||||
| 3463 | painter->setClipRect(clipRect, Qt::IntersectClip); | - | ||||||||||||||||||||||||
| 3464 | else | - | ||||||||||||||||||||||||
| 3465 | painter->setClipPath(clipPath, Qt::IntersectClip); | - | ||||||||||||||||||||||||
| 3466 | } | - | ||||||||||||||||||||||||
| 3467 | - | |||||||||||||||||||||||||
| 3468 | static inline void setWorldTransform(QPainter *painter, const QTransform *const transformPtr, | - | ||||||||||||||||||||||||
| 3469 | const QTransform *effectTransform) | - | ||||||||||||||||||||||||
| 3470 | { | - | ||||||||||||||||||||||||
| 3471 | ((!(transformPtr)) ? qt_assert("transformPtr",__FILE__,48484872) : qt_noop()); | - | ||||||||||||||||||||||||
| 3472 | if (effectTransform) | - | ||||||||||||||||||||||||
| 3473 | painter->setWorldTransform(*transformPtr * *effectTransform); | - | ||||||||||||||||||||||||
| 3474 | else | - | ||||||||||||||||||||||||
| 3475 | painter->setWorldTransform(*transformPtr); | - | ||||||||||||||||||||||||
| 3476 | } | - | ||||||||||||||||||||||||
| 3477 | - | |||||||||||||||||||||||||
| 3478 | void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const QTransform *const viewTransform, | - | ||||||||||||||||||||||||
| 3479 | const QTransform *const transformPtr, QRegion *exposedRegion, QWidget *widget, | - | ||||||||||||||||||||||||
| 3480 | qreal opacity, const QTransform *effectTransform, | - | ||||||||||||||||||||||||
| 3481 | bool wasDirtyParentSceneTransform, bool drawItem) | - | ||||||||||||||||||||||||
| 3482 | { | - | ||||||||||||||||||||||||
| 3483 | const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity); | - | ||||||||||||||||||||||||
| 3484 | const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape); | - | ||||||||||||||||||||||||
| 3485 | const bool itemHasChildren = !item->d_ptr->children.isEmpty(); | - | ||||||||||||||||||||||||
| 3486 | bool setChildClip = itemClipsChildrenToShape; | - | ||||||||||||||||||||||||
| 3487 | bool itemHasChildrenStackedBehind = false; | - | ||||||||||||||||||||||||
| 3488 | - | |||||||||||||||||||||||||
| 3489 | int i = 0; | - | ||||||||||||||||||||||||
| 3490 | if (itemHasChildren) { | - | ||||||||||||||||||||||||
| 3491 | if (itemClipsChildrenToShape) | - | ||||||||||||||||||||||||
| 3492 | setWorldTransform(painter, transformPtr, effectTransform); | - | ||||||||||||||||||||||||
| 3493 | - | |||||||||||||||||||||||||
| 3494 | item->d_ptr->ensureSortedChildren(); | - | ||||||||||||||||||||||||
| 3495 | - | |||||||||||||||||||||||||
| 3496 | - | |||||||||||||||||||||||||
| 3497 | itemHasChildrenStackedBehind = (item->d_ptr->children.at(0)->d_ptr->flags | - | ||||||||||||||||||||||||
| 3498 | & QGraphicsItem::ItemStacksBehindParent); | - | ||||||||||||||||||||||||
| 3499 | - | |||||||||||||||||||||||||
| 3500 | if (itemHasChildrenStackedBehind) { | - | ||||||||||||||||||||||||
| 3501 | if (itemClipsChildrenToShape) { | - | ||||||||||||||||||||||||
| 3502 | setClip(painter, item); | - | ||||||||||||||||||||||||
| 3503 | setChildClip = false; | - | ||||||||||||||||||||||||
| 3504 | } | - | ||||||||||||||||||||||||
| 3505 | - | |||||||||||||||||||||||||
| 3506 | - | |||||||||||||||||||||||||
| 3507 | for (i = 0; i < item->d_ptr->children.size(); ++i) { | - | ||||||||||||||||||||||||
| 3508 | QGraphicsItem *child = item->d_ptr->children.at(i); | - | ||||||||||||||||||||||||
| 3509 | if (wasDirtyParentSceneTransform) | - | ||||||||||||||||||||||||
| 3510 | child->d_ptr->dirtySceneTransform = 1; | - | ||||||||||||||||||||||||
| 3511 | if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent)) | - | ||||||||||||||||||||||||
| 3512 | break; | - | ||||||||||||||||||||||||
| 3513 | if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity)) | - | ||||||||||||||||||||||||
| 3514 | continue; | - | ||||||||||||||||||||||||
| 3515 | drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform); | - | ||||||||||||||||||||||||
| 3516 | } | - | ||||||||||||||||||||||||
| 3517 | } | - | ||||||||||||||||||||||||
| 3518 | } | - | ||||||||||||||||||||||||
| 3519 | - | |||||||||||||||||||||||||
| 3520 | - | |||||||||||||||||||||||||
| 3521 | if (drawItem) { | - | ||||||||||||||||||||||||
| 3522 | ((!(!itemIsFullyTransparent)) ? qt_assert("!itemIsFullyTransparent",__FILE__,48994923) : qt_noop()); | - | ||||||||||||||||||||||||
| 3523 | ((!(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents))) ? qt_assert("!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents)",__FILE__,49004924) : qt_noop()); | - | ||||||||||||||||||||||||
| 3524 | ((!(transformPtr)) ? qt_assert("transformPtr",__FILE__,49014925) : qt_noop()); | - | ||||||||||||||||||||||||
| 3525 | item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion | - | ||||||||||||||||||||||||
| 3526 | ? *exposedRegion : QRegion(), exposedRegion == 0); | - | ||||||||||||||||||||||||
| 3527 | - | |||||||||||||||||||||||||
| 3528 | const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape; | - | ||||||||||||||||||||||||
| 3529 | bool restorePainterClip = false; | - | ||||||||||||||||||||||||
| 3530 | - | |||||||||||||||||||||||||
| 3531 | if (!itemHasChildren || !itemClipsChildrenToShape) { | - | ||||||||||||||||||||||||
| 3532 | - | |||||||||||||||||||||||||
| 3533 | setWorldTransform(painter, transformPtr, effectTransform); | - | ||||||||||||||||||||||||
| 3534 | if ((restorePainterClip = itemClipsToShape)) | - | ||||||||||||||||||||||||
| 3535 | setClip(painter, item); | - | ||||||||||||||||||||||||
| 3536 | } else if (itemHasChildrenStackedBehind){ | - | ||||||||||||||||||||||||
| 3537 | - | |||||||||||||||||||||||||
| 3538 | - | |||||||||||||||||||||||||
| 3539 | if (itemClipsToShape) { | - | ||||||||||||||||||||||||
| 3540 | - | |||||||||||||||||||||||||
| 3541 | setWorldTransform(painter, transformPtr, effectTransform); | - | ||||||||||||||||||||||||
| 3542 | } else { | - | ||||||||||||||||||||||||
| 3543 | - | |||||||||||||||||||||||||
| 3544 | painter->restore(); | - | ||||||||||||||||||||||||
| 3545 | setChildClip = true; | - | ||||||||||||||||||||||||
| 3546 | } | - | ||||||||||||||||||||||||
| 3547 | } else if (itemClipsToShape) { | - | ||||||||||||||||||||||||
| 3548 | - | |||||||||||||||||||||||||
| 3549 | - | |||||||||||||||||||||||||
| 3550 | - | |||||||||||||||||||||||||
| 3551 | setClip(painter, item); | - | ||||||||||||||||||||||||
| 3552 | setChildClip = false; | - | ||||||||||||||||||||||||
| 3553 | } | - | ||||||||||||||||||||||||
| 3554 | - | |||||||||||||||||||||||||
| 3555 | if (painterStateProtection && !restorePainterClip) | - | ||||||||||||||||||||||||
| 3556 | painter->save(); | - | ||||||||||||||||||||||||
| 3557 | - | |||||||||||||||||||||||||
| 3558 | painter->setOpacity(opacity); | - | ||||||||||||||||||||||||
| 3559 | if (!item->d_ptr->cacheMode && !item->d_ptr->isWidget) | - | ||||||||||||||||||||||||
| 3560 | item->paint(painter, &styleOptionTmp, widget); | - | ||||||||||||||||||||||||
| 3561 | else | - | ||||||||||||||||||||||||
| 3562 | drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection); | - | ||||||||||||||||||||||||
| 3563 | - | |||||||||||||||||||||||||
| 3564 | if (painterStateProtection || restorePainterClip) | - | ||||||||||||||||||||||||
| 3565 | painter->restore(); | - | ||||||||||||||||||||||||
| 3566 | - | |||||||||||||||||||||||||
| 3567 | static int drawRect = qEnvironmentVariableIntValue("QT_DRAW_SCENE_ITEM_RECTS"); | - | ||||||||||||||||||||||||
| 3568 | if (drawRect) { | - | ||||||||||||||||||||||||
| 3569 | QPen oldPen = painter->pen(); | - | ||||||||||||||||||||||||
| 3570 | QBrush oldBrush = painter->brush(); | - | ||||||||||||||||||||||||
| 3571 | quintptr ptr = reinterpret_cast<quintptr>(item); | - | ||||||||||||||||||||||||
| 3572 | const QColor color = QColor::fromHsv(ptr % 255, 255, 255); | - | ||||||||||||||||||||||||
| 3573 | painter->setPen(color); | - | ||||||||||||||||||||||||
| 3574 | painter->setBrush(Qt::NoBrush); | - | ||||||||||||||||||||||||
| 3575 | painter->drawRect(adjustedItemBoundingRect(item)); | - | ||||||||||||||||||||||||
| 3576 | painter->setPen(oldPen); | - | ||||||||||||||||||||||||
| 3577 | painter->setBrush(oldBrush); | - | ||||||||||||||||||||||||
| 3578 | } | - | ||||||||||||||||||||||||
| 3579 | } | - | ||||||||||||||||||||||||
| 3580 | - | |||||||||||||||||||||||||
| 3581 | - | |||||||||||||||||||||||||
| 3582 | if (itemHasChildren) { | - | ||||||||||||||||||||||||
| 3583 | if (setChildClip) | - | ||||||||||||||||||||||||
| 3584 | setClip(painter, item); | - | ||||||||||||||||||||||||
| 3585 | - | |||||||||||||||||||||||||
| 3586 | for (; i < item->d_ptr->children.size(); ++i) { | - | ||||||||||||||||||||||||
| 3587 | QGraphicsItem *child = item->d_ptr->children.at(i); | - | ||||||||||||||||||||||||
| 3588 | if (wasDirtyParentSceneTransform) | - | ||||||||||||||||||||||||
| 3589 | child->d_ptr->dirtySceneTransform = 1; | - | ||||||||||||||||||||||||
| 3590 | if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity)) | - | ||||||||||||||||||||||||
| 3591 | continue; | - | ||||||||||||||||||||||||
| 3592 | drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform); | - | ||||||||||||||||||||||||
| 3593 | } | - | ||||||||||||||||||||||||
| 3594 | - | |||||||||||||||||||||||||
| 3595 | - | |||||||||||||||||||||||||
| 3596 | if (itemClipsChildrenToShape) | - | ||||||||||||||||||||||||
| 3597 | painter->restore(); | - | ||||||||||||||||||||||||
| 3598 | } | - | ||||||||||||||||||||||||
| 3599 | } | - | ||||||||||||||||||||||||
| 3600 | - | |||||||||||||||||||||||||
| 3601 | void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren, | - | ||||||||||||||||||||||||
| 3602 | bool force, bool ignoreOpacity, bool removingItemFromScene, | - | ||||||||||||||||||||||||
| 3603 | bool updateBoundingRect) | - | ||||||||||||||||||||||||
| 3604 | { | - | ||||||||||||||||||||||||
| 3605 | ((!(item)) ? qt_assert("item",__FILE__,49825006) : qt_noop()); | - | ||||||||||||||||||||||||
| 3606 | if (updateAll) | - | ||||||||||||||||||||||||
| 3607 | return; | - | ||||||||||||||||||||||||
| 3608 | - | |||||||||||||||||||||||||
| 3609 | if (removingItemFromScene && !ignoreOpacity && !item->d_ptr->ignoreOpacity) { | - | ||||||||||||||||||||||||
| 3610 | - | |||||||||||||||||||||||||
| 3611 | - | |||||||||||||||||||||||||
| 3612 | - | |||||||||||||||||||||||||
| 3613 | - | |||||||||||||||||||||||||
| 3614 | - | |||||||||||||||||||||||||
| 3615 | - | |||||||||||||||||||||||||
| 3616 | - | |||||||||||||||||||||||||
| 3617 | QGraphicsItem *p = item->d_ptr->parent; | - | ||||||||||||||||||||||||
| 3618 | while (p) { | - | ||||||||||||||||||||||||
| 3619 | if (p->d_ptr->ignoreOpacity) { | - | ||||||||||||||||||||||||
| 3620 | item->d_ptr->ignoreOpacity = true; | - | ||||||||||||||||||||||||
| 3621 | break; | - | ||||||||||||||||||||||||
| 3622 | } | - | ||||||||||||||||||||||||
| 3623 | p = p->d_ptr->parent; | - | ||||||||||||||||||||||||
| 3624 | } | - | ||||||||||||||||||||||||
| 3625 | } | - | ||||||||||||||||||||||||
| 3626 | - | |||||||||||||||||||||||||
| 3627 | if (item->d_ptr->discardUpdateRequest( force, | - | ||||||||||||||||||||||||
| 3628 | removingItemFromScene || invalidateChildren, | - | ||||||||||||||||||||||||
| 3629 | ignoreOpacity)) { | - | ||||||||||||||||||||||||
| 3630 | if (item->d_ptr->dirty) { | - | ||||||||||||||||||||||||
| 3631 | - | |||||||||||||||||||||||||
| 3632 | - | |||||||||||||||||||||||||
| 3633 | - | |||||||||||||||||||||||||
| 3634 | - | |||||||||||||||||||||||||
| 3635 | if (force) | - | ||||||||||||||||||||||||
| 3636 | item->d_ptr->ignoreVisible = 1; | - | ||||||||||||||||||||||||
| 3637 | if (ignoreOpacity) | - | ||||||||||||||||||||||||
| 3638 | item->d_ptr->ignoreOpacity = 1; | - | ||||||||||||||||||||||||
| 3639 | } | - | ||||||||||||||||||||||||
| 3640 | return; | - | ||||||||||||||||||||||||
| 3641 | } | - | ||||||||||||||||||||||||
| 3642 | - | |||||||||||||||||||||||||
| 3643 | const bool fullItemUpdate = rect.isNull(); | - | ||||||||||||||||||||||||
| 3644 | if (!fullItemUpdate && rect.isEmpty()) | - | ||||||||||||||||||||||||
| 3645 | return; | - | ||||||||||||||||||||||||
| 3646 | - | |||||||||||||||||||||||||
| 3647 | if (!processDirtyItemsEmitted) { | - | ||||||||||||||||||||||||
| 3648 | QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex); | - | ||||||||||||||||||||||||
| 3649 | method.invoke(q_ptr, Qt::QueuedConnection); | - | ||||||||||||||||||||||||
| 3650 | - | |||||||||||||||||||||||||
| 3651 | processDirtyItemsEmitted = true; | - | ||||||||||||||||||||||||
| 3652 | } | - | ||||||||||||||||||||||||
| 3653 | - | |||||||||||||||||||||||||
| 3654 | if (removingItemFromScene) { | - | ||||||||||||||||||||||||
| 3655 | - | |||||||||||||||||||||||||
| 3656 | - | |||||||||||||||||||||||||
| 3657 | if (isSignalConnected(changedSignalIndex) || views.isEmpty()) { | - | ||||||||||||||||||||||||
| 3658 | - | |||||||||||||||||||||||||
| 3659 | - | |||||||||||||||||||||||||
| 3660 | - | |||||||||||||||||||||||||
| 3661 | q_func()->update(); | - | ||||||||||||||||||||||||
| 3662 | return; | - | ||||||||||||||||||||||||
| 3663 | } | - | ||||||||||||||||||||||||
| 3664 | - | |||||||||||||||||||||||||
| 3665 | for (int i = 0; i < views.size(); ++i) { | - | ||||||||||||||||||||||||
| 3666 | QGraphicsViewPrivate *viewPrivate = views.at(i)->d_func(); | - | ||||||||||||||||||||||||
| 3667 | QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport); | - | ||||||||||||||||||||||||
| 3668 | rect.translate(viewPrivate->dirtyScrollOffset); | - | ||||||||||||||||||||||||
| 3669 | viewPrivate->updateRect(rect); | - | ||||||||||||||||||||||||
| 3670 | } | - | ||||||||||||||||||||||||
| 3671 | return; | - | ||||||||||||||||||||||||
| 3672 | } | - | ||||||||||||||||||||||||
| 3673 | - | |||||||||||||||||||||||||
| 3674 | bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents; | - | ||||||||||||||||||||||||
| 3675 | if (!hasNoContents) { | - | ||||||||||||||||||||||||
| 3676 | item->d_ptr->dirty = 1; | - | ||||||||||||||||||||||||
| 3677 | if (fullItemUpdate) | - | ||||||||||||||||||||||||
| 3678 | item->d_ptr->fullUpdatePending = 1; | - | ||||||||||||||||||||||||
| 3679 | else if (!item->d_ptr->fullUpdatePending) | - | ||||||||||||||||||||||||
| 3680 | item->d_ptr->needsRepaint |= rect; | - | ||||||||||||||||||||||||
| 3681 | } else if (item->d_ptr->graphicsEffect) { | - | ||||||||||||||||||||||||
| 3682 | invalidateChildren = true; | - | ||||||||||||||||||||||||
| 3683 | } | - | ||||||||||||||||||||||||
| 3684 | - | |||||||||||||||||||||||||
| 3685 | if (invalidateChildren) { | - | ||||||||||||||||||||||||
| 3686 | item->d_ptr->allChildrenDirty = 1; | - | ||||||||||||||||||||||||
| 3687 | item->d_ptr->dirtyChildren = 1; | - | ||||||||||||||||||||||||
| 3688 | } | - | ||||||||||||||||||||||||
| 3689 | - | |||||||||||||||||||||||||
| 3690 | if (force) | - | ||||||||||||||||||||||||
| 3691 | item->d_ptr->ignoreVisible = 1; | - | ||||||||||||||||||||||||
| 3692 | if (ignoreOpacity) | - | ||||||||||||||||||||||||
| 3693 | item->d_ptr->ignoreOpacity = 1; | - | ||||||||||||||||||||||||
| 3694 | - | |||||||||||||||||||||||||
| 3695 | if (!updateBoundingRect) | - | ||||||||||||||||||||||||
| 3696 | item->d_ptr->markParentDirty(); | - | ||||||||||||||||||||||||
| 3697 | } | - | ||||||||||||||||||||||||
| 3698 | - | |||||||||||||||||||||||||
| 3699 | static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item, | - | ||||||||||||||||||||||||
| 3700 | const QRectF &rect, bool itemIsUntransformable) | - | ||||||||||||||||||||||||
| 3701 | { | - | ||||||||||||||||||||||||
| 3702 | ((!(view)) ? qt_assert("view",__FILE__,50795103) : qt_noop()); | - | ||||||||||||||||||||||||
| 3703 | ((!(item)) ? qt_assert("item",__FILE__,50805104) : qt_noop()); | - | ||||||||||||||||||||||||
| 3704 | - | |||||||||||||||||||||||||
| 3705 | QGraphicsItem *itemq = static_cast<QGraphicsItem *>(item->q_ptr); | - | ||||||||||||||||||||||||
| 3706 | QGraphicsView *viewq = static_cast<QGraphicsView *>(view->q_ptr); | - | ||||||||||||||||||||||||
| 3707 | - | |||||||||||||||||||||||||
| 3708 | if (itemIsUntransformable) { | - | ||||||||||||||||||||||||
| 3709 | const QTransform xform = itemq->deviceTransform(viewq->viewportTransform()); | - | ||||||||||||||||||||||||
| 3710 | if (!item->hasBoundingRegionGranularity) | - | ||||||||||||||||||||||||
| 3711 | return view->updateRectF(xform.mapRect(rect)); | - | ||||||||||||||||||||||||
| 3712 | return view->updateRegion(rect, xform); | - | ||||||||||||||||||||||||
| 3713 | } | - | ||||||||||||||||||||||||
| 3714 | - | |||||||||||||||||||||||||
| 3715 | if (item->sceneTransformTranslateOnly && view->identityMatrix) { | - | ||||||||||||||||||||||||
| 3716 | const qreal dx = item->sceneTransform.dx(); | - | ||||||||||||||||||||||||
| 3717 | const qreal dy = item->sceneTransform.dy(); | - | ||||||||||||||||||||||||
| 3718 | QRectF r(rect); | - | ||||||||||||||||||||||||
| 3719 | r.translate(dx - view->horizontalScroll(), dy - view->verticalScroll()); | - | ||||||||||||||||||||||||
| 3720 | return view->updateRectF(r); | - | ||||||||||||||||||||||||
| 3721 | } | - | ||||||||||||||||||||||||
| 3722 | - | |||||||||||||||||||||||||
| 3723 | if (!viewq->isTransformed()) { | - | ||||||||||||||||||||||||
| 3724 | if (!item->hasBoundingRegionGranularity) | - | ||||||||||||||||||||||||
| 3725 | return view->updateRectF(item->sceneTransform.mapRect(rect)); | - | ||||||||||||||||||||||||
| 3726 | return view->updateRegion(rect, item->sceneTransform); | - | ||||||||||||||||||||||||
| 3727 | } | - | ||||||||||||||||||||||||
| 3728 | - | |||||||||||||||||||||||||
| 3729 | QTransform xform = item->sceneTransform; | - | ||||||||||||||||||||||||
| 3730 | xform *= viewq->viewportTransform(); | - | ||||||||||||||||||||||||
| 3731 | if (!item->hasBoundingRegionGranularity) | - | ||||||||||||||||||||||||
| 3732 | return view->updateRectF(xform.mapRect(rect)); | - | ||||||||||||||||||||||||
| 3733 | return view->updateRegion(rect, xform); | - | ||||||||||||||||||||||||
| 3734 | } | - | ||||||||||||||||||||||||
| 3735 | - | |||||||||||||||||||||||||
| 3736 | void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren, | - | ||||||||||||||||||||||||
| 3737 | qreal parentOpacity) | - | ||||||||||||||||||||||||
| 3738 | { | - | ||||||||||||||||||||||||
| 3739 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 3740 | ((!(item)) ? qt_assert("item",__FILE__,51175141) : qt_noop()); | - | ||||||||||||||||||||||||
| 3741 | ((!(!updateAll)) ? qt_assert("!updateAll",__FILE__,51185142) : qt_noop()); | - | ||||||||||||||||||||||||
| 3742 | - | |||||||||||||||||||||||||
| 3743 | if (!item->d_ptr->dirty && !item->d_ptr->dirtyChildren) { | - | ||||||||||||||||||||||||
| 3744 | resetDirtyItem(item); | - | ||||||||||||||||||||||||
| 3745 | return; | - | ||||||||||||||||||||||||
| 3746 | } | - | ||||||||||||||||||||||||
| 3747 | - | |||||||||||||||||||||||||
| 3748 | const bool itemIsHidden = !item->d_ptr->ignoreVisible && !item->d_ptr->visible; | - | ||||||||||||||||||||||||
| 3749 | if (itemIsHidden) { | - | ||||||||||||||||||||||||
| 3750 | resetDirtyItem(item, true); | - | ||||||||||||||||||||||||
| 3751 | return; | - | ||||||||||||||||||||||||
| 3752 | } | - | ||||||||||||||||||||||||
| 3753 | - | |||||||||||||||||||||||||
| 3754 | bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents); | - | ||||||||||||||||||||||||
| 3755 | const bool itemHasChildren = !item->d_ptr->children.isEmpty(); | - | ||||||||||||||||||||||||
| 3756 | if (!itemHasContents) { | - | ||||||||||||||||||||||||
| 3757 | if (!itemHasChildren) { | - | ||||||||||||||||||||||||
| 3758 | resetDirtyItem(item); | - | ||||||||||||||||||||||||
| 3759 | return; | - | ||||||||||||||||||||||||
| 3760 | } | - | ||||||||||||||||||||||||
| 3761 | if (item->d_ptr->graphicsEffect) | - | ||||||||||||||||||||||||
| 3762 | itemHasContents = true; | - | ||||||||||||||||||||||||
| 3763 | } | - | ||||||||||||||||||||||||
| 3764 | - | |||||||||||||||||||||||||
| 3765 | const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity); | - | ||||||||||||||||||||||||
| 3766 | const bool itemIsFullyTransparent = !item->d_ptr->ignoreOpacity | - | ||||||||||||||||||||||||
| 3767 | && QGraphicsItemPrivate::isOpacityNull(opacity); | - | ||||||||||||||||||||||||
| 3768 | if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity())) { | - | ||||||||||||||||||||||||
| 3769 | resetDirtyItem(item, itemHasChildren); | - | ||||||||||||||||||||||||
| 3770 | return; | - | ||||||||||||||||||||||||
| 3771 | } | - | ||||||||||||||||||||||||
| 3772 | - | |||||||||||||||||||||||||
| 3773 | bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform; | - | ||||||||||||||||||||||||
| 3774 | const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable(); | - | ||||||||||||||||||||||||
| 3775 | if (wasDirtyParentSceneTransform && !itemIsUntransformable) { | - | ||||||||||||||||||||||||
| 3776 | item->d_ptr->updateSceneTransformFromParent(); | - | ||||||||||||||||||||||||
| 3777 | ((!(!item->d_ptr->dirtySceneTransform)) ? qt_assert("!item->d_ptr->dirtySceneTransform",__FILE__,51545178) : qt_noop()); | - | ||||||||||||||||||||||||
| 3778 | } | - | ||||||||||||||||||||||||
| 3779 | - | |||||||||||||||||||||||||
| 3780 | const bool wasDirtyParentViewBoundingRects = item->d_ptr->paintedViewBoundingRectsNeedRepaint; | - | ||||||||||||||||||||||||
| 3781 | if (itemIsFullyTransparent || !itemHasContents || dirtyAncestorContainsChildren) { | - | ||||||||||||||||||||||||
| 3782 | - | |||||||||||||||||||||||||
| 3783 | item->d_ptr->dirty = 0; | - | ||||||||||||||||||||||||
| 3784 | item->d_ptr->fullUpdatePending = 0; | - | ||||||||||||||||||||||||
| 3785 | - | |||||||||||||||||||||||||
| 3786 | if (itemIsFullyTransparent || !itemHasContents) | - | ||||||||||||||||||||||||
| 3787 | item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0; | - | ||||||||||||||||||||||||
| 3788 | } | - | ||||||||||||||||||||||||
| 3789 | - | |||||||||||||||||||||||||
| 3790 | if (!hasSceneRect && item->d_ptr->geometryChanged && item->d_ptr->visible) { | - | ||||||||||||||||||||||||
| 3791 | - | |||||||||||||||||||||||||
| 3792 | if (item->d_ptr->sceneTransformTranslateOnly) { | - | ||||||||||||||||||||||||
| 3793 | growingItemsBoundingRect |= item->boundingRect().translated(item->d_ptr->sceneTransform.dx(), | - | ||||||||||||||||||||||||
| 3794 | item->d_ptr->sceneTransform.dy()); | - | ||||||||||||||||||||||||
| 3795 | } else { | - | ||||||||||||||||||||||||
| 3796 | growingItemsBoundingRect |= item->d_ptr->sceneTransform.mapRect(item->boundingRect()); | - | ||||||||||||||||||||||||
| 3797 | } | - | ||||||||||||||||||||||||
| 3798 | } | - | ||||||||||||||||||||||||
| 3799 | - | |||||||||||||||||||||||||
| 3800 | - | |||||||||||||||||||||||||
| 3801 | if (item->d_ptr->dirty || item->d_ptr->paintedViewBoundingRectsNeedRepaint) { | - | ||||||||||||||||||||||||
| 3802 | const bool useCompatUpdate = views.isEmpty() || isSignalConnected(changedSignalIndex); | - | ||||||||||||||||||||||||
| 3803 | const QRectF itemBoundingRect = adjustedItemEffectiveBoundingRect(item); | - | ||||||||||||||||||||||||
| 3804 | - | |||||||||||||||||||||||||
| 3805 | if (useCompatUpdate && !itemIsUntransformable && qFuzzyIsNull(item->boundingRegionGranularity())) { | - | ||||||||||||||||||||||||
| 3806 | - | |||||||||||||||||||||||||
| 3807 | - | |||||||||||||||||||||||||
| 3808 | - | |||||||||||||||||||||||||
| 3809 | if (item->d_ptr->sceneTransformTranslateOnly) { | - | ||||||||||||||||||||||||
| 3810 | q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(), | - | ||||||||||||||||||||||||
| 3811 | item->d_ptr->sceneTransform.dy())); | - | ||||||||||||||||||||||||
| 3812 | } else { | - | ||||||||||||||||||||||||
| 3813 | QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect); | - | ||||||||||||||||||||||||
| 3814 | if (!rect.isEmpty()) | - | ||||||||||||||||||||||||
| 3815 | q->update(rect); | - | ||||||||||||||||||||||||
| 3816 | } | - | ||||||||||||||||||||||||
| 3817 | } else { | - | ||||||||||||||||||||||||
| 3818 | QRectF dirtyRect; | - | ||||||||||||||||||||||||
| 3819 | bool uninitializedDirtyRect = true; | - | ||||||||||||||||||||||||
| 3820 | - | |||||||||||||||||||||||||
| 3821 | for (int j = 0; j < views.size(); ++j) { | - | ||||||||||||||||||||||||
| 3822 | QGraphicsView *view = views.at(j); | - | ||||||||||||||||||||||||
| 3823 | QGraphicsViewPrivate *viewPrivate = view->d_func(); | - | ||||||||||||||||||||||||
| 3824 | QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport]; | - | ||||||||||||||||||||||||
| 3825 | if (viewPrivate->fullUpdatePending | - | ||||||||||||||||||||||||
| 3826 | || viewPrivate->viewportUpdateMode == QGraphicsView::NoViewportUpdate) { | - | ||||||||||||||||||||||||
| 3827 | - | |||||||||||||||||||||||||
| 3828 | - | |||||||||||||||||||||||||
| 3829 | - | |||||||||||||||||||||||||
| 3830 | paintedViewBoundingRect = QRect(-1, -1, -1, -1); | - | ||||||||||||||||||||||||
| 3831 | continue; | - | ||||||||||||||||||||||||
| 3832 | } | - | ||||||||||||||||||||||||
| 3833 | - | |||||||||||||||||||||||||
| 3834 | if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) { | - | ||||||||||||||||||||||||
| 3835 | paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset); | - | ||||||||||||||||||||||||
| 3836 | if (!viewPrivate->updateRect(paintedViewBoundingRect)) | - | ||||||||||||||||||||||||
| 3837 | paintedViewBoundingRect = QRect(-1, -1, -1, -1); | - | ||||||||||||||||||||||||
| 3838 | } | - | ||||||||||||||||||||||||
| 3839 | - | |||||||||||||||||||||||||
| 3840 | if (!item->d_ptr->dirty) | - | ||||||||||||||||||||||||
| 3841 | continue; | - | ||||||||||||||||||||||||
| 3842 | - | |||||||||||||||||||||||||
| 3843 | if (!item->d_ptr->paintedViewBoundingRectsNeedRepaint | - | ||||||||||||||||||||||||
| 3844 | && paintedViewBoundingRect.x() == -1 && paintedViewBoundingRect.y() == -1 | - | ||||||||||||||||||||||||
| 3845 | && paintedViewBoundingRect.width() == -1 && paintedViewBoundingRect.height() == -1) { | - | ||||||||||||||||||||||||
| 3846 | continue; | - | ||||||||||||||||||||||||
| 3847 | } | - | ||||||||||||||||||||||||
| 3848 | - | |||||||||||||||||||||||||
| 3849 | if (uninitializedDirtyRect) { | - | ||||||||||||||||||||||||
| 3850 | dirtyRect = itemBoundingRect; | - | ||||||||||||||||||||||||
| 3851 | if (!item->d_ptr->fullUpdatePending) { | - | ||||||||||||||||||||||||
| 3852 | _q_adjustRect(&item->d_ptr->needsRepaint); | - | ||||||||||||||||||||||||
| 3853 | dirtyRect &= item->d_ptr->needsRepaint; | - | ||||||||||||||||||||||||
| 3854 | } | - | ||||||||||||||||||||||||
| 3855 | uninitializedDirtyRect = false; | - | ||||||||||||||||||||||||
| 3856 | } | - | ||||||||||||||||||||||||
| 3857 | - | |||||||||||||||||||||||||
| 3858 | if (dirtyRect.isEmpty()) | - | ||||||||||||||||||||||||
| 3859 | continue; | - | ||||||||||||||||||||||||
| 3860 | - | |||||||||||||||||||||||||
| 3861 | if (!updateHelper(viewPrivate, item->d_ptr.data(), dirtyRect, itemIsUntransformable) | - | ||||||||||||||||||||||||
| 3862 | && item->d_ptr->paintedViewBoundingRectsNeedRepaint) { | - | ||||||||||||||||||||||||
| 3863 | paintedViewBoundingRect = QRect(-1, -1, -1, -1); | - | ||||||||||||||||||||||||
| 3864 | } | - | ||||||||||||||||||||||||
| 3865 | } | - | ||||||||||||||||||||||||
| 3866 | } | - | ||||||||||||||||||||||||
| 3867 | } | - | ||||||||||||||||||||||||
| 3868 | - | |||||||||||||||||||||||||
| 3869 | - | |||||||||||||||||||||||||
| 3870 | if (itemHasChildren && item->d_ptr->dirtyChildren) { | - | ||||||||||||||||||||||||
| 3871 | const bool itemClipsChildrenToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape | - | ||||||||||||||||||||||||
| 3872 | || item->d_ptr->flags & QGraphicsItem::ItemContainsChildrenInShape; | - | ||||||||||||||||||||||||
| 3873 | - | |||||||||||||||||||||||||
| 3874 | - | |||||||||||||||||||||||||
| 3875 | - | |||||||||||||||||||||||||
| 3876 | - | |||||||||||||||||||||||||
| 3877 | const bool bypassUpdateClip = !itemHasContents && wasDirtyParentViewBoundingRects; | - | ||||||||||||||||||||||||
| 3878 | if (itemClipsChildrenToShape && !bypassUpdateClip) { | - | ||||||||||||||||||||||||
| 3879 | - | |||||||||||||||||||||||||
| 3880 | for (int i = 0; i < views.size(); ++i) | - | ||||||||||||||||||||||||
| 3881 | views.at(i)->d_func()->setUpdateClip(item); | - | ||||||||||||||||||||||||
| 3882 | } | - | ||||||||||||||||||||||||
| 3883 | if (!dirtyAncestorContainsChildren) { | - | ||||||||||||||||||||||||
| 3884 | dirtyAncestorContainsChildren = item->d_ptr->fullUpdatePending | - | ||||||||||||||||||||||||
| 3885 | && itemClipsChildrenToShape; | - | ||||||||||||||||||||||||
| 3886 | } | - | ||||||||||||||||||||||||
| 3887 | const bool allChildrenDirty = item->d_ptr->allChildrenDirty; | - | ||||||||||||||||||||||||
| 3888 | const bool parentIgnoresVisible = item->d_ptr->ignoreVisible; | - | ||||||||||||||||||||||||
| 3889 | const bool parentIgnoresOpacity = item->d_ptr->ignoreOpacity; | - | ||||||||||||||||||||||||
| 3890 | for (int i = 0; i < item->d_ptr->children.size(); ++i) { | - | ||||||||||||||||||||||||
| 3891 | QGraphicsItem *child = item->d_ptr->children.at(i); | - | ||||||||||||||||||||||||
| 3892 | if (wasDirtyParentSceneTransform) | - | ||||||||||||||||||||||||
| 3893 | child->d_ptr->dirtySceneTransform = 1; | - | ||||||||||||||||||||||||
| 3894 | if (wasDirtyParentViewBoundingRects) | - | ||||||||||||||||||||||||
| 3895 | child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1; | - | ||||||||||||||||||||||||
| 3896 | if (parentIgnoresVisible) | - | ||||||||||||||||||||||||
| 3897 | child->d_ptr->ignoreVisible = 1; | - | ||||||||||||||||||||||||
| 3898 | if (parentIgnoresOpacity) | - | ||||||||||||||||||||||||
| 3899 | child->d_ptr->ignoreOpacity = 1; | - | ||||||||||||||||||||||||
| 3900 | if (allChildrenDirty) { | - | ||||||||||||||||||||||||
| 3901 | child->d_ptr->dirty = 1; | - | ||||||||||||||||||||||||
| 3902 | child->d_ptr->fullUpdatePending = 1; | - | ||||||||||||||||||||||||
| 3903 | child->d_ptr->dirtyChildren = 1; | - | ||||||||||||||||||||||||
| 3904 | child->d_ptr->allChildrenDirty = 1; | - | ||||||||||||||||||||||||
| 3905 | } | - | ||||||||||||||||||||||||
| 3906 | processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity); | - | ||||||||||||||||||||||||
| 3907 | } | - | ||||||||||||||||||||||||
| 3908 | - | |||||||||||||||||||||||||
| 3909 | if (itemClipsChildrenToShape) { | - | ||||||||||||||||||||||||
| 3910 | - | |||||||||||||||||||||||||
| 3911 | for (int i = 0; i < views.size(); ++i) | - | ||||||||||||||||||||||||
| 3912 | views.at(i)->d_func()->setUpdateClip(0); | - | ||||||||||||||||||||||||
| 3913 | } | - | ||||||||||||||||||||||||
| 3914 | } else if (wasDirtyParentSceneTransform) { | - | ||||||||||||||||||||||||
| 3915 | item->d_ptr->invalidateChildrenSceneTransform(); | - | ||||||||||||||||||||||||
| 3916 | } | - | ||||||||||||||||||||||||
| 3917 | - | |||||||||||||||||||||||||
| 3918 | resetDirtyItem(item); | - | ||||||||||||||||||||||||
| 3919 | } | - | ||||||||||||||||||||||||
| 3920 | void QGraphicsScene::drawItems(QPainter *painter, | - | ||||||||||||||||||||||||
| 3921 | int numItems, | - | ||||||||||||||||||||||||
| 3922 | QGraphicsItem *items[], | - | ||||||||||||||||||||||||
| 3923 | const QStyleOptionGraphicsItem options[], QWidget *widget) | - | ||||||||||||||||||||||||
| 3924 | { | - | ||||||||||||||||||||||||
| 3925 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 3926 | - | |||||||||||||||||||||||||
| 3927 | if (!d->unpolishedItems.isEmpty()) | - | ||||||||||||||||||||||||
| 3928 | d->_q_polishItems(); | - | ||||||||||||||||||||||||
| 3929 | - | |||||||||||||||||||||||||
| 3930 | const qreal opacity = painter->opacity(); | - | ||||||||||||||||||||||||
| 3931 | QTransform viewTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 3932 | (void)options;; | - | ||||||||||||||||||||||||
| 3933 | - | |||||||||||||||||||||||||
| 3934 | - | |||||||||||||||||||||||||
| 3935 | QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0; | - | ||||||||||||||||||||||||
| 3936 | QRegion *expose = 0; | - | ||||||||||||||||||||||||
| 3937 | const quint32 oldRectAdjust = d->rectAdjust; | - | ||||||||||||||||||||||||
| 3938 | if (view) { | - | ||||||||||||||||||||||||
| 3939 | d->updateAll = false; | - | ||||||||||||||||||||||||
| 3940 | expose = &view->d_func()->exposedRegion; | - | ||||||||||||||||||||||||
| 3941 | if (view->d_func()->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) | - | ||||||||||||||||||||||||
| 3942 | d->rectAdjust = 1; | - | ||||||||||||||||||||||||
| 3943 | else | - | ||||||||||||||||||||||||
| 3944 | d->rectAdjust = 2; | - | ||||||||||||||||||||||||
| 3945 | } | - | ||||||||||||||||||||||||
| 3946 | - | |||||||||||||||||||||||||
| 3947 | - | |||||||||||||||||||||||||
| 3948 | QList<QGraphicsItem *> topLevelItems; | - | ||||||||||||||||||||||||
| 3949 | for (int i = 0; i < numItems; ++i) { | - | ||||||||||||||||||||||||
| 3950 | QGraphicsItem *item = items[i]->topLevelItem(); | - | ||||||||||||||||||||||||
| 3951 | if (!item->d_ptr->itemDiscovered) { | - | ||||||||||||||||||||||||
| 3952 | topLevelItems << item; | - | ||||||||||||||||||||||||
| 3953 | item->d_ptr->itemDiscovered = 1; | - | ||||||||||||||||||||||||
| 3954 | d->drawSubtreeRecursive(item, painter, &viewTransform, expose, widget); | - | ||||||||||||||||||||||||
| 3955 | } | - | ||||||||||||||||||||||||
| 3956 | } | - | ||||||||||||||||||||||||
| 3957 | - | |||||||||||||||||||||||||
| 3958 | d->rectAdjust = oldRectAdjust; | - | ||||||||||||||||||||||||
| 3959 | - | |||||||||||||||||||||||||
| 3960 | for (int i = 0; i < topLevelItems.size(); ++i) | - | ||||||||||||||||||||||||
| 3961 | topLevelItems.at(i)->d_ptr->itemDiscovered = 0; | - | ||||||||||||||||||||||||
| 3962 | - | |||||||||||||||||||||||||
| 3963 | painter->setWorldTransform(viewTransform); | - | ||||||||||||||||||||||||
| 3964 | painter->setOpacity(opacity); | - | ||||||||||||||||||||||||
| 3965 | } | - | ||||||||||||||||||||||||
| 3966 | bool QGraphicsScene::focusNextPrevChild(bool next) | - | ||||||||||||||||||||||||
| 3967 | { | - | ||||||||||||||||||||||||
| 3968 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 3969 | - | |||||||||||||||||||||||||
| 3970 | QGraphicsItem *item = focusItem(); | - | ||||||||||||||||||||||||
| 3971 | if (item && !item->isWidget()) { | - | ||||||||||||||||||||||||
| 3972 | - | |||||||||||||||||||||||||
| 3973 | return false; | - | ||||||||||||||||||||||||
| 3974 | } | - | ||||||||||||||||||||||||
| 3975 | if (!item) { | - | ||||||||||||||||||||||||
| 3976 | if (d->lastFocusItem && !d->lastFocusItem->isWidget()) { | - | ||||||||||||||||||||||||
| 3977 | - | |||||||||||||||||||||||||
| 3978 | - | |||||||||||||||||||||||||
| 3979 | setFocusItem(d->lastFocusItem, next ? Qt::TabFocusReason : Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
| 3980 | return true; | - | ||||||||||||||||||||||||
| 3981 | } | - | ||||||||||||||||||||||||
| 3982 | if (d->activePanel) { | - | ||||||||||||||||||||||||
| 3983 | if (d->activePanel->flags() & QGraphicsItem::ItemIsFocusable) { | - | ||||||||||||||||||||||||
| 3984 | setFocusItem(d->activePanel, next ? Qt::TabFocusReason : Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
| 3985 | return true; | - | ||||||||||||||||||||||||
| 3986 | } | - | ||||||||||||||||||||||||
| 3987 | if (d->activePanel->isWidget()) { | - | ||||||||||||||||||||||||
| 3988 | QGraphicsWidget *fw = static_cast<QGraphicsWidget *>(d->activePanel)->d_func()->focusNext; | - | ||||||||||||||||||||||||
| 3989 | do { | - | ||||||||||||||||||||||||
| 3990 | if (fw->focusPolicy() & Qt::TabFocus) { | - | ||||||||||||||||||||||||
| 3991 | setFocusItem(fw, next ? Qt::TabFocusReason : Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
| 3992 | return true; | - | ||||||||||||||||||||||||
| 3993 | } | - | ||||||||||||||||||||||||
| 3994 | } while (fw != d->activePanel); | - | ||||||||||||||||||||||||
| 3995 | } | - | ||||||||||||||||||||||||
| 3996 | } | - | ||||||||||||||||||||||||
| 3997 | } | - | ||||||||||||||||||||||||
| 3998 | if (!item && !d->tabFocusFirst) { | - | ||||||||||||||||||||||||
| 3999 | - | |||||||||||||||||||||||||
| 4000 | return false; | - | ||||||||||||||||||||||||
| 4001 | } | - | ||||||||||||||||||||||||
| 4002 | - | |||||||||||||||||||||||||
| 4003 | - | |||||||||||||||||||||||||
| 4004 | QGraphicsWidget *widget = 0; | - | ||||||||||||||||||||||||
| 4005 | if (!item) { | - | ||||||||||||||||||||||||
| 4006 | widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev; | - | ||||||||||||||||||||||||
| 4007 | } else { | - | ||||||||||||||||||||||||
| 4008 | QGraphicsWidget *test = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
| 4009 | widget = next ? test->d_func()->focusNext : test->d_func()->focusPrev; | - | ||||||||||||||||||||||||
| 4010 | if (!widget->panel() && ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))) { | - | ||||||||||||||||||||||||
| 4011 | - | |||||||||||||||||||||||||
| 4012 | return false; | - | ||||||||||||||||||||||||
| 4013 | } | - | ||||||||||||||||||||||||
| 4014 | } | - | ||||||||||||||||||||||||
| 4015 | QGraphicsWidget *widgetThatHadFocus = widget; | - | ||||||||||||||||||||||||
| 4016 | - | |||||||||||||||||||||||||
| 4017 | - | |||||||||||||||||||||||||
| 4018 | do { | - | ||||||||||||||||||||||||
| 4019 | if (widget->flags() & QGraphicsItem::ItemIsFocusable | - | ||||||||||||||||||||||||
| 4020 | && widget->isEnabled() && widget->isVisibleTo(0) | - | ||||||||||||||||||||||||
| 4021 | && (widget->focusPolicy() & Qt::TabFocus) | - | ||||||||||||||||||||||||
| 4022 | && (!item || !item->isPanel() || item->isAncestorOf(widget)) | - | ||||||||||||||||||||||||
| 4023 | ) { | - | ||||||||||||||||||||||||
| 4024 | setFocusItem(widget, next ? Qt::TabFocusReason : Qt::BacktabFocusReason); | - | ||||||||||||||||||||||||
| 4025 | return true; | - | ||||||||||||||||||||||||
| 4026 | } | - | ||||||||||||||||||||||||
| 4027 | widget = next ? widget->d_func()->focusNext : widget->d_func()->focusPrev; | - | ||||||||||||||||||||||||
| 4028 | if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev)) | - | ||||||||||||||||||||||||
| 4029 | return false; | - | ||||||||||||||||||||||||
| 4030 | } while (widget != widgetThatHadFocus); | - | ||||||||||||||||||||||||
| 4031 | - | |||||||||||||||||||||||||
| 4032 | return false; | - | ||||||||||||||||||||||||
| 4033 | } | - | ||||||||||||||||||||||||
| 4034 | QStyle *QGraphicsScene::style() const | - | ||||||||||||||||||||||||
| 4035 | { | - | ||||||||||||||||||||||||
| 4036 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4037 | - | |||||||||||||||||||||||||
| 4038 | return d->style ? d->style : QApplication::style(); | - | ||||||||||||||||||||||||
| 4039 | } | - | ||||||||||||||||||||||||
| 4040 | void QGraphicsScene::setStyle(QStyle *style) | - | ||||||||||||||||||||||||
| 4041 | { | - | ||||||||||||||||||||||||
| 4042 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4043 | - | |||||||||||||||||||||||||
| 4044 | if (style == d->style
| 0 | ||||||||||||||||||||||||
| 4045 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4046 | - | |||||||||||||||||||||||||
| 4047 | - | |||||||||||||||||||||||||
| 4048 | delete d->style; | - | ||||||||||||||||||||||||
| 4049 | if ((
| 0 | ||||||||||||||||||||||||
| 4050 | d->style->setParent(this); never executed: d->style->setParent(this); | 0 | ||||||||||||||||||||||||
| 4051 | - | |||||||||||||||||||||||||
| 4052 | - | |||||||||||||||||||||||||
| 4053 | QEvent event(QEvent::StyleChange); | - | ||||||||||||||||||||||||
| 4054 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||
| 4055 | - | |||||||||||||||||||||||||
| 4056 | - | |||||||||||||||||||||||||
| 4057 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(items())>::type> _container_((items())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^const auto items_ = 1)items(); | - | ||||||||||||||||||||||||
| 4058 | for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0: items_) { | - | ||||||||||||||||||||||||
| 4059 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
| 4060 | QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
| 4061 | if (!widget->testAttribute(Qt::WA_SetStyle)
| 0 | ||||||||||||||||||||||||
| 4062 | QApplication::sendEvent(widget, &event); never executed: QApplication::sendEvent(widget, &event); | 0 | ||||||||||||||||||||||||
| 4063 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4064 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4065 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4066 | QFont QGraphicsScene::font() const | - | ||||||||||||||||||||||||
| 4067 | { | - | ||||||||||||||||||||||||
| 4068 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4069 | return d->font; | - | ||||||||||||||||||||||||
| 4070 | } | - | ||||||||||||||||||||||||
| 4071 | void QGraphicsScene::setFont(const QFont &font) | - | ||||||||||||||||||||||||
| 4072 | { | - | ||||||||||||||||||||||||
| 4073 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4074 | QFont naturalFont = QApplication::font(); | - | ||||||||||||||||||||||||
| 4075 | naturalFont.resolve(0); | - | ||||||||||||||||||||||||
| 4076 | QFont resolvedFont = font.resolve(naturalFont); | - | ||||||||||||||||||||||||
| 4077 | d->setFont_helper(resolvedFont); | - | ||||||||||||||||||||||||
| 4078 | } | - | ||||||||||||||||||||||||
| 4079 | QPalette QGraphicsScene::palette() const | - | ||||||||||||||||||||||||
| 4080 | { | - | ||||||||||||||||||||||||
| 4081 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4082 | return d->palette; | - | ||||||||||||||||||||||||
| 4083 | } | - | ||||||||||||||||||||||||
| 4084 | void QGraphicsScene::setPalette(const QPalette &palette) | - | ||||||||||||||||||||||||
| 4085 | { | - | ||||||||||||||||||||||||
| 4086 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4087 | QPalette naturalPalette = QApplication::palette(); | - | ||||||||||||||||||||||||
| 4088 | naturalPalette.resolve(0); | - | ||||||||||||||||||||||||
| 4089 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - | ||||||||||||||||||||||||
| 4090 | d->setPalette_helper(resolvedPalette); | - | ||||||||||||||||||||||||
| 4091 | } | - | ||||||||||||||||||||||||
| 4092 | bool QGraphicsScene::isActive() const | - | ||||||||||||||||||||||||
| 4093 | { | - | ||||||||||||||||||||||||
| 4094 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4095 | return d->activationRefCount > 0; | - | ||||||||||||||||||||||||
| 4096 | } | - | ||||||||||||||||||||||||
| 4097 | - | |||||||||||||||||||||||||
| 4098 | - | |||||||||||||||||||||||||
| 4099 | - | |||||||||||||||||||||||||
| 4100 | - | |||||||||||||||||||||||||
| 4101 | - | |||||||||||||||||||||||||
| 4102 | - | |||||||||||||||||||||||||
| 4103 | - | |||||||||||||||||||||||||
| 4104 | QGraphicsItem *QGraphicsScene::activePanel() const | - | ||||||||||||||||||||||||
| 4105 | { | - | ||||||||||||||||||||||||
| 4106 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4107 | return d->activePanel; | - | ||||||||||||||||||||||||
| 4108 | } | - | ||||||||||||||||||||||||
| 4109 | void QGraphicsScene::setActivePanel(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 4110 | { | - | ||||||||||||||||||||||||
| 4111 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4112 | d->setActivePanelHelper(item, false); | - | ||||||||||||||||||||||||
| 4113 | } | - | ||||||||||||||||||||||||
| 4114 | QGraphicsWidget *QGraphicsScene::activeWindow() const | - | ||||||||||||||||||||||||
| 4115 | { | - | ||||||||||||||||||||||||
| 4116 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4117 | if (d->activePanel && d->activePanel->isWindow()) | - | ||||||||||||||||||||||||
| 4118 | return static_cast<QGraphicsWidget *>(d->activePanel); | - | ||||||||||||||||||||||||
| 4119 | return 0; | - | ||||||||||||||||||||||||
| 4120 | } | - | ||||||||||||||||||||||||
| 4121 | void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
| 4122 | { | - | ||||||||||||||||||||||||
| 4123 | if (widget
| 0 | ||||||||||||||||||||||||
| 4124 | QMessageLogger(__FILE__, 57205745, __PRETTY_FUNCTION__).warning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene", | - | ||||||||||||||||||||||||
| 4125 | widget); | - | ||||||||||||||||||||||||
| 4126 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4127 | } | - | ||||||||||||||||||||||||
| 4128 | - | |||||||||||||||||||||||||
| 4129 | - | |||||||||||||||||||||||||
| 4130 | QGraphicsItem *panel = widget
| 0 | ||||||||||||||||||||||||
| 4131 | setActivePanel(panel); | - | ||||||||||||||||||||||||
| 4132 | - | |||||||||||||||||||||||||
| 4133 | - | |||||||||||||||||||||||||
| 4134 | if (panel
| 0 | ||||||||||||||||||||||||
| 4135 | QList<QGraphicsItem *> siblingWindows;QGraphicsItem *parent = panel->parentItem(); | - | ||||||||||||||||||||||||
| 4136 | - | |||||||||||||||||||||||||
| 4137 | - | |||||||||||||||||||||||||
| 4138 | - | |||||||||||||||||||||||||
| 4139 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(parent ? parentqreal z = panel->childItems() : items())>::type> _container_((zValue(); | - | ||||||||||||||||||||||||
| 4140 | const auto siblings = parent
| 0 | ||||||||||||||||||||||||
| 4141 | for (QGraphicsItem *sibling = *_container_.i; _container_.control; _container_.control = 0: siblings) { | - | ||||||||||||||||||||||||
| 4142 | if (sibling != panel
| 0 | ||||||||||||||||||||||||
| 4143 | siblingWindows << sibling; | 0 | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| qreal z = panel->zValue(); | ||||||||||||||||||||||||||
| for (int i = 0; i < siblingWindows.size(); ++i)z = qMax(z, siblingWindows.at(i)->sibling->zValue()); never executed: z = qMax(z, sibling->zValue()); | ||||||||||||||||||||||||||
| 4144 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4145 | - | |||||||||||||||||||||||||
| 4146 | - | |||||||||||||||||||||||||
| 4147 | const qreal litt = qreal(0.001); | - | ||||||||||||||||||||||||
| 4148 | panel->setZValue(z + litt); | - | ||||||||||||||||||||||||
| 4149 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4150 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4151 | bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event) | - | ||||||||||||||||||||||||
| 4152 | { | - | ||||||||||||||||||||||||
| 4153 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4154 | if (!item) { | - | ||||||||||||||||||||||||
| 4155 | QMessageLogger(__FILE__, 57665789, __PRETTY_FUNCTION__).warning("QGraphicsScene::sendEvent: cannot send event to a null item"); | - | ||||||||||||||||||||||||
| 4156 | return false; | - | ||||||||||||||||||||||||
| 4157 | } | - | ||||||||||||||||||||||||
| 4158 | if (item->scene() != this) { | - | ||||||||||||||||||||||||
| 4159 | QMessageLogger(__FILE__, 57705793, __PRETTY_FUNCTION__).warning("QGraphicsScene::sendEvent: item %p's scene (%p)" | - | ||||||||||||||||||||||||
| 4160 | " is different from this scene (%p)", | - | ||||||||||||||||||||||||
| 4161 | item, item->scene(), this); | - | ||||||||||||||||||||||||
| 4162 | return false; | - | ||||||||||||||||||||||||
| 4163 | } | - | ||||||||||||||||||||||||
| 4164 | return d->sendEvent(item, event); | - | ||||||||||||||||||||||||
| 4165 | } | - | ||||||||||||||||||||||||
| 4166 | qreal QGraphicsScene::minimumRenderSize() const | - | ||||||||||||||||||||||||
| 4167 | { | - | ||||||||||||||||||||||||
| 4168 | const QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4169 | return d->minimumRenderSize; | - | ||||||||||||||||||||||||
| 4170 | } | - | ||||||||||||||||||||||||
| 4171 | void QGraphicsScene::setMinimumRenderSize(qreal minSize) | - | ||||||||||||||||||||||||
| 4172 | { | - | ||||||||||||||||||||||||
| 4173 | QGraphicsScenePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 4174 | d->minimumRenderSize = minSize; | - | ||||||||||||||||||||||||
| 4175 | update(); | - | ||||||||||||||||||||||||
| 4176 | } | - | ||||||||||||||||||||||||
| 4177 | - | |||||||||||||||||||||||||
| 4178 | void QGraphicsScenePrivate::addView(QGraphicsView *view) | - | ||||||||||||||||||||||||
| 4179 | { | - | ||||||||||||||||||||||||
| 4180 | views << view; | - | ||||||||||||||||||||||||
| 4181 | - | |||||||||||||||||||||||||
| 4182 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(grabbedGestures.keys())>::type> _container_((const auto gestures = grabbedGestures.keys())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||||||||
| 4183 | for (Qt::GestureType gesture = *_container_.i; _container_.control; _container_.control = 0: gestures) | - | ||||||||||||||||||||||||
| 4184 | view->viewport()->grabGesture(gesture); never executed: view->viewport()->grabGesture(gesture); | 0 | ||||||||||||||||||||||||
| 4185 | - | |||||||||||||||||||||||||
| 4186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4187 | - | |||||||||||||||||||||||||
| 4188 | void QGraphicsScenePrivate::removeView(QGraphicsView *view) | - | ||||||||||||||||||||||||
| 4189 | { | - | ||||||||||||||||||||||||
| 4190 | views.removeAll(view); | - | ||||||||||||||||||||||||
| 4191 | } | - | ||||||||||||||||||||||||
| 4192 | - | |||||||||||||||||||||||||
| 4193 | void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent) | - | ||||||||||||||||||||||||
| 4194 | { | - | ||||||||||||||||||||||||
| 4195 | QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();for (int i = 0; i < touchPoints.count(); ++iauto &touchPoint : touchEvent->_touchPoints) { | - | ||||||||||||||||||||||||
| 4196 | QTouchEvent::TouchPoint &touchPoint = touchPoints[i];touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect()); | - | ||||||||||||||||||||||||
| 4197 | touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), static_cast<QWidget *>(touchEvent->target()))); | - | ||||||||||||||||||||||||
| 4198 | touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), static_cast<QWidget *>(touchEvent->target()))); | - | ||||||||||||||||||||||||
| 4199 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| touchEvent->setTouchPoints(touchPoints);} never executed: end of block | ||||||||||||||||||||||||||
| 4201 | - | |||||||||||||||||||||||||
| 4202 | int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos) | - | ||||||||||||||||||||||||
| 4203 | { | - | ||||||||||||||||||||||||
| 4204 | int closestTouchPointId = -1; | - | ||||||||||||||||||||||||
| 4205 | qreal closestDistance = qreal(0.); | - | ||||||||||||||||||||||||
| 4206 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(sceneCurrentTouchPoints)>::type> _container_((sceneCurrentTouchPoints)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QTouchEvent::TouchPoint &touchPoint = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 4207 | qreal distance = QLineF(scenePos, touchPoint.scenePos()).length(); | - | ||||||||||||||||||||||||
| 4208 | if (closestTouchPointId == -1|| distance < closestDistance) { | - | ||||||||||||||||||||||||
| 4209 | closestTouchPointId = touchPoint.id(); | - | ||||||||||||||||||||||||
| 4210 | closestDistance = distance; | - | ||||||||||||||||||||||||
| 4211 | } | - | ||||||||||||||||||||||||
| 4212 | } | - | ||||||||||||||||||||||||
| 4213 | return closestTouchPointId; | - | ||||||||||||||||||||||||
| 4214 | } | - | ||||||||||||||||||||||||
| 4215 | - | |||||||||||||||||||||||||
| 4216 | void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) | - | ||||||||||||||||||||||||
| 4217 | { | - | ||||||||||||||||||||||||
| 4218 | typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; | - | ||||||||||||||||||||||||
| 4219 | QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents; | - | ||||||||||||||||||||||||
| 4220 | - | |||||||||||||||||||||||||
| 4221 | for (int i = 0; i < sceneTouchEvent->touchPoints().count()
| 0 | ||||||||||||||||||||||||
| 4222 | const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i); | - | ||||||||||||||||||||||||
| 4223 | - | |||||||||||||||||||||||||
| 4224 | - | |||||||||||||||||||||||||
| 4225 | QGraphicsItem *item = 0; | - | ||||||||||||||||||||||||
| 4226 | if (touchPoint.state() == Qt::TouchPointPressed
| 0 | ||||||||||||||||||||||||
| 4227 | if (sceneTouchEvent->device()->type() == QTouchDevice::TouchPad
| 0 | ||||||||||||||||||||||||
| 4228 | - | |||||||||||||||||||||||||
| 4229 | item = itemForTouchPointId.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4230 | ? 0 | - | ||||||||||||||||||||||||
| 4231 | : itemForTouchPointId.constBegin().value(); | - | ||||||||||||||||||||||||
| 4232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4233 | - | |||||||||||||||||||||||||
| 4234 | if (!item
| 0 | ||||||||||||||||||||||||
| 4235 | - | |||||||||||||||||||||||||
| 4236 | cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(), | - | ||||||||||||||||||||||||
| 4237 | touchPoint.scenePos(), | - | ||||||||||||||||||||||||
| 4238 | static_cast<QWidget *>(sceneTouchEvent->target())); | - | ||||||||||||||||||||||||
| 4239 | item = cachedItemsUnderMouse.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4240 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4241 | - | |||||||||||||||||||||||||
| 4242 | if (sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen
| 0 | ||||||||||||||||||||||||
| 4243 | - | |||||||||||||||||||||||||
| 4244 | int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos()); | - | ||||||||||||||||||||||||
| 4245 | QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId); | - | ||||||||||||||||||||||||
| 4246 | if (!item
| 0 | ||||||||||||||||||||||||
| 4247 | item = closestItem; never executed: item = closestItem; | 0 | ||||||||||||||||||||||||
| 4248 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4249 | if (!item
| 0 | ||||||||||||||||||||||||
| 4250 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4251 | - | |||||||||||||||||||||||||
| 4252 | itemForTouchPointId.insert(touchPoint.id(), item); | - | ||||||||||||||||||||||||
| 4253 | sceneCurrentTouchPoints.insert(touchPoint.id(), touchPoint); | - | ||||||||||||||||||||||||
| 4254 | } never executed: else if (touchPoint.state() == Qt::TouchPointReleasedend of block
| 0 | ||||||||||||||||||||||||
| 4255 | item = itemForTouchPointId.take(touchPoint.id()); | - | ||||||||||||||||||||||||
| 4256 | if (!item
| 0 | ||||||||||||||||||||||||
| 4257 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4258 | - | |||||||||||||||||||||||||
| 4259 | sceneCurrentTouchPoints.remove(touchPoint.id()); | - | ||||||||||||||||||||||||
| 4260 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 4261 | item = itemForTouchPointId.value(touchPoint.id()); | - | ||||||||||||||||||||||||
| 4262 | if (!item
| 0 | ||||||||||||||||||||||||
| 4263 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4264 | ((!(sceneCurrentTouchPoints.contains(touchPoint.id()))) ? qt_assert("sceneCurrentTouchPoints.contains(touchPoint.id())",__FILE__,59095930) : qt_noop()); | - | ||||||||||||||||||||||||
| 4265 | sceneCurrentTouchPoints[touchPoint.id()] = touchPoint; | - | ||||||||||||||||||||||||
| 4266 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4267 | - | |||||||||||||||||||||||||
| 4268 | StatesAndTouchPoints &statesAndTouchPoints = itemsNeedingEvents[item]; | - | ||||||||||||||||||||||||
| 4269 | statesAndTouchPoints.first |= touchPoint.state(); | - | ||||||||||||||||||||||||
| 4270 | statesAndTouchPoints.second.append(touchPoint); | - | ||||||||||||||||||||||||
| 4271 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4272 | - | |||||||||||||||||||||||||
| 4273 | if (itemsNeedingEvents.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4274 | sceneTouchEvent->ignore(); | - | ||||||||||||||||||||||||
| 4275 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4276 | } | - | ||||||||||||||||||||||||
| 4277 | - | |||||||||||||||||||||||||
| 4278 | bool ignoreSceneTouchEvent = true; | - | ||||||||||||||||||||||||
| 4279 | QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin(); | - | ||||||||||||||||||||||||
| 4280 | const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd(); | - | ||||||||||||||||||||||||
| 4281 | for (; it != end
| 0 | ||||||||||||||||||||||||
| 4282 | QGraphicsItem *item = it.key(); | - | ||||||||||||||||||||||||
| 4283 | - | |||||||||||||||||||||||||
| 4284 | (void) item->isBlockedByModalPanel(&item); | - | ||||||||||||||||||||||||
| 4285 | - | |||||||||||||||||||||||||
| 4286 | - | |||||||||||||||||||||||||
| 4287 | QEvent::Type eventType; | - | ||||||||||||||||||||||||
| 4288 | switch (it.value().first) { | - | ||||||||||||||||||||||||
| 4289 | case never executed: Qt::TouchPointPressed:case Qt::TouchPointPressed:never executed: case Qt::TouchPointPressed: | 0 | ||||||||||||||||||||||||
| 4290 | - | |||||||||||||||||||||||||
| 4291 | eventType = QEvent::TouchBegin; | - | ||||||||||||||||||||||||
| 4292 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4293 | case never executed: Qt::TouchPointReleased:case Qt::TouchPointReleased:never executed: case Qt::TouchPointReleased: | 0 | ||||||||||||||||||||||||
| 4294 | - | |||||||||||||||||||||||||
| 4295 | eventType = QEvent::TouchEnd; | - | ||||||||||||||||||||||||
| 4296 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4297 | case never executed: Qt::TouchPointStationary:case Qt::TouchPointStationary:never executed: case Qt::TouchPointStationary: | 0 | ||||||||||||||||||||||||
| 4298 | - | |||||||||||||||||||||||||
| 4299 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4300 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 4301 | - | |||||||||||||||||||||||||
| 4302 | eventType = QEvent::TouchUpdate; | - | ||||||||||||||||||||||||
| 4303 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4304 | } | - | ||||||||||||||||||||||||
| 4305 | - | |||||||||||||||||||||||||
| 4306 | QTouchEvent touchEvent(eventType); | - | ||||||||||||||||||||||||
| 4307 | touchEvent.setWindow(sceneTouchEvent->window()); | - | ||||||||||||||||||||||||
| 4308 | touchEvent.setTarget(sceneTouchEvent->target()); | - | ||||||||||||||||||||||||
| 4309 | touchEvent.setDevice(sceneTouchEvent->device()); | - | ||||||||||||||||||||||||
| 4310 | touchEvent.setModifiers(sceneTouchEvent->modifiers()); | - | ||||||||||||||||||||||||
| 4311 | touchEvent.setTouchPointStates(it.value().first); | - | ||||||||||||||||||||||||
| 4312 | touchEvent.setTouchPoints(it.value().second); | - | ||||||||||||||||||||||||
| 4313 | touchEvent.setTimestamp(sceneTouchEvent->timestamp()); | - | ||||||||||||||||||||||||
| 4314 | - | |||||||||||||||||||||||||
| 4315 | switch (touchEvent.type()) { | - | ||||||||||||||||||||||||
| 4316 | case never executed: QEvent::TouchBegin:case QEvent::TouchBegin:never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||||||||
| 4317 | { | - | ||||||||||||||||||||||||
| 4318 | - | |||||||||||||||||||||||||
| 4319 | - | |||||||||||||||||||||||||
| 4320 | item->d_ptr->acceptedTouchBeginEvent = true; | - | ||||||||||||||||||||||||
| 4321 | bool res = sendTouchBeginEvent(item, &touchEvent)
| 0 | ||||||||||||||||||||||||
| 4322 | && touchEvent.isAccepted()
| 0 | ||||||||||||||||||||||||
| 4323 | if (!res
| 0 | ||||||||||||||||||||||||
| 4324 | - | |||||||||||||||||||||||||
| 4325 | for (int i = 0; i < touchEvent.touchPoints().count()
| 0 | ||||||||||||||||||||||||
| 4326 | const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i); | - | ||||||||||||||||||||||||
| 4327 | itemForTouchPointId.remove(touchPoint.id()); | - | ||||||||||||||||||||||||
| 4328 | sceneCurrentTouchPoints.remove(touchPoint.id()); | - | ||||||||||||||||||||||||
| 4329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4330 | ignoreSceneTouchEvent = false; | - | ||||||||||||||||||||||||
| 4331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4332 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4333 | } | - | ||||||||||||||||||||||||
| 4334 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 4335 | if (item->d_ptr->acceptedTouchBeginEvent
| 0 | ||||||||||||||||||||||||
| 4336 | updateTouchPointsForItem(item, &touchEvent); | - | ||||||||||||||||||||||||
| 4337 | (void) sendEvent(item, &touchEvent); | - | ||||||||||||||||||||||||
| 4338 | ignoreSceneTouchEvent = false; | - | ||||||||||||||||||||||||
| 4339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4340 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4341 | } | - | ||||||||||||||||||||||||
| 4342 | } | - | ||||||||||||||||||||||||
| 4343 | sceneTouchEvent->setAccepted(ignoreSceneTouchEvent); | - | ||||||||||||||||||||||||
| 4344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4345 | - | |||||||||||||||||||||||||
| 4346 | bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEvent *touchEvent) | - | ||||||||||||||||||||||||
| 4347 | { | - | ||||||||||||||||||||||||
| 4348 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 4349 | - | |||||||||||||||||||||||||
| 4350 | if (cachedItemsUnderMouse.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4351 | const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); | - | ||||||||||||||||||||||||
| 4352 | cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), | - | ||||||||||||||||||||||||
| 4353 | firstTouchPoint.scenePos(), | - | ||||||||||||||||||||||||
| 4354 | static_cast<QWidget *>(touchEvent->target())); | - | ||||||||||||||||||||||||
| 4355 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4356 | - | |||||||||||||||||||||||||
| 4357 | - | |||||||||||||||||||||||||
| 4358 | bool setFocus = false; | - | ||||||||||||||||||||||||
| 4359 | - | |||||||||||||||||||||||||
| 4360 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(cachedItemsUnderMouse)>::type> _container_((cachedItemsUnderMouse)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 4361 | if (item->isEnabled()
| 0 | ||||||||||||||||||||||||
| 4362 | if (!item->isWidget()
| 0 | ||||||||||||||||||||||||
| 4363 | setFocus = true; | - | ||||||||||||||||||||||||
| 4364 | if (item != q->focusItem()
| 0 | ||||||||||||||||||||||||
| 4365 | q->setFocusItem(item, Qt::MouseFocusReason); never executed: q->setFocusItem(item, Qt::MouseFocusReason); | 0 | ||||||||||||||||||||||||
| 4366 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4367 | } | - | ||||||||||||||||||||||||
| 4368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4369 | if (item->isPanel()
| 0 | ||||||||||||||||||||||||
| 4370 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4371 | if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation
| 0 | ||||||||||||||||||||||||
| 4372 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4373 | if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling
| 0 | ||||||||||||||||||||||||
| 4374 | - | |||||||||||||||||||||||||
| 4375 | setFocus = true; | - | ||||||||||||||||||||||||
| 4376 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4377 | } | - | ||||||||||||||||||||||||
| 4378 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4379 | - | |||||||||||||||||||||||||
| 4380 | - | |||||||||||||||||||||||||
| 4381 | if (!stickyFocus
| 0 | ||||||||||||||||||||||||
| 4382 | q->setFocusItem(0, Qt::MouseFocusReason); never executed: q->setFocusItem(0, Qt::MouseFocusReason); | 0 | ||||||||||||||||||||||||
| 4383 | - | |||||||||||||||||||||||||
| 4384 | bool res = false; | - | ||||||||||||||||||||||||
| 4385 | bool eventAccepted = touchEvent->isAccepted(); | - | ||||||||||||||||||||||||
| 4386 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(cachedItemsUnderMouse)>::type> _container_((cachedItemsUnderMouse)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsItem *item = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 4387 | - | |||||||||||||||||||||||||
| 4388 | updateTouchPointsForItem(item, touchEvent); | - | ||||||||||||||||||||||||
| 4389 | bool acceptTouchEvents = item->acceptTouchEvents(); | - | ||||||||||||||||||||||||
| 4390 | touchEvent->setAccepted(acceptTouchEvents); | - | ||||||||||||||||||||||||
| 4391 | res = acceptTouchEvents
| 0 | ||||||||||||||||||||||||
| 4392 | eventAccepted = touchEvent->isAccepted(); | - | ||||||||||||||||||||||||
| 4393 | if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0
| 0 | ||||||||||||||||||||||||
| 4394 | - | |||||||||||||||||||||||||
| 4395 | item = 0; | - | ||||||||||||||||||||||||
| 4396 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 4397 | item->d_ptr->acceptedTouchBeginEvent = (res
| 0 | ||||||||||||||||||||||||
| 4398 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4399 | touchEvent->spont = false; | - | ||||||||||||||||||||||||
| 4400 | if (res
| 0 | ||||||||||||||||||||||||
| 4401 | - | |||||||||||||||||||||||||
| 4402 | for (int i = 0; i < touchEvent->touchPoints().count()
| 0 | ||||||||||||||||||||||||
| 4403 | const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i); | - | ||||||||||||||||||||||||
| 4404 | itemForTouchPointId[touchPoint.id()] = item; | - | ||||||||||||||||||||||||
| 4405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4406 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4407 | } | - | ||||||||||||||||||||||||
| 4408 | if (item
| 0 | ||||||||||||||||||||||||
| 4409 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4410 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4411 | - | |||||||||||||||||||||||||
| 4412 | touchEvent->setAccepted(eventAccepted); | - | ||||||||||||||||||||||||
| 4413 | return never executed: res;return res;never executed: return res; | 0 | ||||||||||||||||||||||||
| 4414 | } | - | ||||||||||||||||||||||||
| 4415 | - | |||||||||||||||||||||||||
| 4416 | void QGraphicsScenePrivate::enableTouchEventsOnViews() | - | ||||||||||||||||||||||||
| 4417 | { | - | ||||||||||||||||||||||||
| 4418 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(views)>::type> _container_((views)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsView *view = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
| 4419 | view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true); | - | ||||||||||||||||||||||||
| 4420 | } | - | ||||||||||||||||||||||||
| 4421 | - | |||||||||||||||||||||||||
| 4422 | void QGraphicsScenePrivate::updateInputMethodSensitivityInViews() | - | ||||||||||||||||||||||||
| 4423 | { | - | ||||||||||||||||||||||||
| 4424 | for (int i = 0; i < views.size(); ++i) | - | ||||||||||||||||||||||||
| 4425 | views.at(i)->d_func()->updateInputMethodSensitivity(); | - | ||||||||||||||||||||||||
| 4426 | } | - | ||||||||||||||||||||||||
| 4427 | - | |||||||||||||||||||||||||
| 4428 | void QGraphicsScenePrivate::enterModal(QGraphicsItem *panel, QGraphicsItem::PanelModality previousModality) | - | ||||||||||||||||||||||||
| 4429 | { | - | ||||||||||||||||||||||||
| 4430 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 4431 | ((!(panel && panel->isPanel())) ? qt_assert("panel && panel->isPanel()",__FILE__,60766097) : qt_noop()); | - | ||||||||||||||||||||||||
| 4432 | - | |||||||||||||||||||||||||
| 4433 | QGraphicsItem::PanelModality panelModality = panel->d_ptr->panelModality; | - | ||||||||||||||||||||||||
| 4434 | if (previousModality != QGraphicsItem::NonModal
| 0 | ||||||||||||||||||||||||
| 4435 | - | |||||||||||||||||||||||||
| 4436 | - | |||||||||||||||||||||||||
| 4437 | panel->d_ptr->panelModality = previousModality; | - | ||||||||||||||||||||||||
| 4438 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4439 | - | |||||||||||||||||||||||||
| 4440 | QSet<QGraphicsItem *> blockedPanels; | - | ||||||||||||||||||||||||
| 4441 | QList<QGraphicsItem *> items = q->items(); | - | ||||||||||||||||||||||||
| 4442 | for (int i = 0; i < items.count()
| 0 | ||||||||||||||||||||||||
| 4443 | QGraphicsItem *item = items.at(i); | - | ||||||||||||||||||||||||
| 4444 | if (item->isPanel()
| 0 | ||||||||||||||||||||||||
| 4445 | blockedPanels.insert(item); never executed: blockedPanels.insert(item); | 0 | ||||||||||||||||||||||||
| 4446 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4447 | - | |||||||||||||||||||||||||
| 4448 | - | |||||||||||||||||||||||||
| 4449 | if (previousModality != QGraphicsItem::NonModal
| 0 | ||||||||||||||||||||||||
| 4450 | - | |||||||||||||||||||||||||
| 4451 | panel->d_ptr->panelModality = panelModality; | - | ||||||||||||||||||||||||
| 4452 | - | |||||||||||||||||||||||||
| 4453 | modalPanels.removeAll(panel); | - | ||||||||||||||||||||||||
| 4454 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4455 | - | |||||||||||||||||||||||||
| 4456 | modalPanels.prepend(panel); | - | ||||||||||||||||||||||||
| 4457 | - | |||||||||||||||||||||||||
| 4458 | if (!hoverItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4459 | - | |||||||||||||||||||||||||
| 4460 | QGraphicsSceneHoverEvent hoverEvent; | - | ||||||||||||||||||||||||
| 4461 | hoverEvent.setScenePos(lastSceneMousePos); | - | ||||||||||||||||||||||||
| 4462 | dispatchHoverEvent(&hoverEvent); | - | ||||||||||||||||||||||||
| 4463 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4464 | - | |||||||||||||||||||||||||
| 4465 | if (!mouseGrabberItems.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4466 | QGraphicsItem *item = mouseGrabberItems.lastconstLast(); | - | ||||||||||||||||||||||||
| 4467 | if (item->isBlockedByModalPanel()
| 0 | ||||||||||||||||||||||||
| 4468 | ungrabMouse(item, false); never executed: ungrabMouse(item, false); | 0 | ||||||||||||||||||||||||
| 4469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4470 | - | |||||||||||||||||||||||||
| 4471 | QEvent windowBlockedEvent(QEvent::WindowBlocked); | - | ||||||||||||||||||||||||
| 4472 | QEvent windowUnblockedEvent(QEvent::WindowUnblocked); | - | ||||||||||||||||||||||||
| 4473 | for (int i = 0; i < items.count()
| 0 | ||||||||||||||||||||||||
| 4474 | QGraphicsItem *item = items.at(i); | - | ||||||||||||||||||||||||
| 4475 | if (item->isPanel()
| 0 | ||||||||||||||||||||||||
| 4476 | if (!blockedPanels.contains(item)
| 0 | ||||||||||||||||||||||||
| 4477 | - | |||||||||||||||||||||||||
| 4478 | sendEvent(item, &windowBlockedEvent); | - | ||||||||||||||||||||||||
| 4479 | } never executed: else if (blockedPanels.contains(item)end of block
| 0 | ||||||||||||||||||||||||
| 4480 | - | |||||||||||||||||||||||||
| 4481 | - | |||||||||||||||||||||||||
| 4482 | sendEvent(item, &windowUnblockedEvent); | - | ||||||||||||||||||||||||
| 4483 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4484 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4485 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4486 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4487 | - | |||||||||||||||||||||||||
| 4488 | void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel) | - | ||||||||||||||||||||||||
| 4489 | { | - | ||||||||||||||||||||||||
| 4490 | QGraphicsScene * const q = q_func(); | - | ||||||||||||||||||||||||
| 4491 | ((!(panel && panel->isPanel())) ? qt_assert("panel && panel->isPanel()",__FILE__,61366157) : qt_noop()); | - | ||||||||||||||||||||||||
| 4492 | - | |||||||||||||||||||||||||
| 4493 | QSet<QGraphicsItem *> blockedPanels; | - | ||||||||||||||||||||||||
| 4494 | QList<QGraphicsItem *> items = q->items(); | - | ||||||||||||||||||||||||
| 4495 | for (int i = 0; i < items.count(); ++i) { | - | ||||||||||||||||||||||||
| 4496 | QGraphicsItem *item = items.at(i); | - | ||||||||||||||||||||||||
| 4497 | if (item->isPanel() && item->isBlockedByModalPanel()) | - | ||||||||||||||||||||||||
| 4498 | blockedPanels.insert(item); | - | ||||||||||||||||||||||||
| 4499 | } | - | ||||||||||||||||||||||||
| 4500 | - | |||||||||||||||||||||||||
| 4501 | modalPanels.removeAll(panel); | - | ||||||||||||||||||||||||
| 4502 | - | |||||||||||||||||||||||||
| 4503 | QEvent e(QEvent::WindowUnblocked); | - | ||||||||||||||||||||||||
| 4504 | for (int i = 0; i < items.count(); ++i) { | - | ||||||||||||||||||||||||
| 4505 | QGraphicsItem *item = items.at(i); | - | ||||||||||||||||||||||||
| 4506 | if (item->isPanel() && blockedPanels.contains(item) && !item->isBlockedByModalPanel()) | - | ||||||||||||||||||||||||
| 4507 | sendEvent(item, &e); | - | ||||||||||||||||||||||||
| 4508 | } | - | ||||||||||||||||||||||||
| 4509 | - | |||||||||||||||||||||||||
| 4510 | - | |||||||||||||||||||||||||
| 4511 | QGraphicsSceneHoverEvent hoverEvent; | - | ||||||||||||||||||||||||
| 4512 | hoverEvent.setScenePos(lastSceneMousePos); | - | ||||||||||||||||||||||||
| 4513 | dispatchHoverEvent(&hoverEvent); | - | ||||||||||||||||||||||||
| 4514 | } | - | ||||||||||||||||||||||||
| 4515 | - | |||||||||||||||||||||||||
| 4516 | - | |||||||||||||||||||||||||
| 4517 | void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures, | - | ||||||||||||||||||||||||
| 4518 | Qt::GestureFlag flag, | - | ||||||||||||||||||||||||
| 4519 | QHash<QGraphicsObject *, QSet<QGesture *> > *targets, | - | ||||||||||||||||||||||||
| 4520 | QSet<QGraphicsObject *> *itemsSet, | - | ||||||||||||||||||||||||
| 4521 | QSet<QGesture *> *normal, | - | ||||||||||||||||||||||||
| 4522 | QSet<QGesture *> *conflicts) | - | ||||||||||||||||||||||||
| 4523 | { | - | ||||||||||||||||||||||||
| 4524 | QSet<QGesture *> normalGestures; | - | ||||||||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||||||||
| 4525 | ++_container_.i, _container_.control ^= 1)for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0: gestures) { | - | ||||||||||||||||||||||||
| 4526 | if (!gesture->hasHotSpot()
| 0 | ||||||||||||||||||||||||
| 4527 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4528 | const Qt::GestureType gestureType = gesture->gestureType(); | - | ||||||||||||||||||||||||
| 4529 | QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0); | - | ||||||||||||||||||||||||
| 4530 | for (int j = 0; j < items.size()
| 0 | ||||||||||||||||||||||||
| 4531 | QGraphicsItem *item = items.at(j); | - | ||||||||||||||||||||||||
| 4532 | - | |||||||||||||||||||||||||
| 4533 | - | |||||||||||||||||||||||||
| 4534 | - | |||||||||||||||||||||||||
| 4535 | (void) item->isBlockedByModalPanel(&item); | - | ||||||||||||||||||||||||
| 4536 | - | |||||||||||||||||||||||||
| 4537 | if (QGraphicsObject *itemobj = item->toGraphicsObject()
| 0 | ||||||||||||||||||||||||
| 4538 | QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); | - | ||||||||||||||||||||||||
| 4539 | QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it = | - | ||||||||||||||||||||||||
| 4540 | d->gestureContext.constFind(gestureType); | - | ||||||||||||||||||||||||
| 4541 | if (it != d->gestureContext.constEnd()
| 0 | ||||||||||||||||||||||||
| 4542 | if (normalGestures.contains(gesture)
| 0 | ||||||||||||||||||||||||
| 4543 | normalGestures.remove(gesture); | - | ||||||||||||||||||||||||
| 4544 | if (conflicts
| 0 | ||||||||||||||||||||||||
| 4545 | conflicts->insert(gesture); never executed: conflicts->insert(gesture); | 0 | ||||||||||||||||||||||||
| 4546 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 4547 | normalGestures.insert(gesture); | - | ||||||||||||||||||||||||
| 4548 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4549 | if (targets
| 0 | ||||||||||||||||||||||||
| 4550 | (* never executed: targets)[itemobj].insert(gesture);(*targets)[itemobj].insert(gesture);never executed: (*targets)[itemobj].insert(gesture); | 0 | ||||||||||||||||||||||||
| 4551 | if (itemsSet
| 0 | ||||||||||||||||||||||||
| 4552 | (* never executed: itemsSet).insert(itemobj);(*itemsSet).insert(itemobj);never executed: (*itemsSet).insert(itemobj); | 0 | ||||||||||||||||||||||||
| 4553 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4554 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4555 | - | |||||||||||||||||||||||||
| 4556 | if (item->isPanel()
| 0 | ||||||||||||||||||||||||
| 4557 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4558 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4559 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4560 | if (normal
| 0 | ||||||||||||||||||||||||
| 4561 | * never executed: normal = normalGestures;*normal = normalGestures;never executed: *normal = normalGestures; | 0 | ||||||||||||||||||||||||
| 4562 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4563 | - | |||||||||||||||||||||||||
| 4564 | void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) | - | ||||||||||||||||||||||||
| 4565 | { | - | ||||||||||||||||||||||||
| 4566 | QWidget *viewport = event->widget(); | - | ||||||||||||||||||||||||
| 4567 | if (!viewport
| 0 | ||||||||||||||||||||||||
| 4568 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4569 | QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport->parent()); | - | ||||||||||||||||||||||||
| 4570 | if (!graphicsView
| 0 | ||||||||||||||||||||||||
| 4571 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4572 | - | |||||||||||||||||||||||||
| 4573 | const QList<QGesture *> allGestures = event->gestures(); | - | ||||||||||||||||||||||||
| 4574 | if (0) QMessageLogger(__FILE__, 62196240, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" dead code: QMessageLogger(__FILE__, 6240, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Gestures:" << allGestures; | - | ||||||||||||||||||||||||
| 4575 | << "Gestures:" << allGestures; dead code: QMessageLogger(__FILE__, 6240, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Gestures:" << allGestures; | - | ||||||||||||||||||||||||
| 4576 | - | |||||||||||||||||||||||||
| 4577 | QSet<QGesture *> startedGestures; | - | ||||||||||||||||||||||||
| 4578 | QPoint delta = viewport->mapFromGlobal(QPoint()); | - | ||||||||||||||||||||||||
| 4579 | QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y()) | - | ||||||||||||||||||||||||
| 4580 | * graphicsView->viewportTransform().inverted(); | - | ||||||||||||||||||||||||
| 4581 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(allGestures)>::type> _container_((allGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0: allGestures) { | - | ||||||||||||||||||||||||
| 4582 | - | |||||||||||||||||||||||||
| 4583 | if (gesture->hasHotSpot()
| 0 | ||||||||||||||||||||||||
| 4584 | gesture->d_func()->sceneHotSpot = toScene.map(gesture->hotSpot()); | - | ||||||||||||||||||||||||
| 4585 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 4586 | gesture->d_func()->sceneHotSpot = QPointF(); | - | ||||||||||||||||||||||||
| 4587 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4588 | - | |||||||||||||||||||||||||
| 4589 | QGraphicsObject *target = gestureTargets.value(gesture, 0); | - | ||||||||||||||||||||||||
| 4590 | if (!target
| 0 | ||||||||||||||||||||||||
| 4591 | - | |||||||||||||||||||||||||
| 4592 | - | |||||||||||||||||||||||||
| 4593 | if (gesture->state() == Qt::GestureStarted
| 0 | ||||||||||||||||||||||||
| 4594 | startedGestures.insert(gesture); never executed: startedGestures.insert(gesture); | 0 | ||||||||||||||||||||||||
| 4595 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4596 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4597 | - | |||||||||||||||||||||||||
| 4598 | if (!startedGestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4599 | QSet<QGesture *> normalGestures; | - | ||||||||||||||||||||||||
| 4600 | QSet<QGesture *> conflictedGestures; | - | ||||||||||||||||||||||||
| 4601 | gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0, | - | ||||||||||||||||||||||||
| 4602 | &normalGestures, &conflictedGestures); | - | ||||||||||||||||||||||||
| 4603 | cachedTargetItems = cachedItemGestures.keys(); | - | ||||||||||||||||||||||||
| 4604 | std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); | - | ||||||||||||||||||||||||
| 4605 | if (0) QMessageLogger(__FILE__, 62506271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" dead code: QMessageLogger(__FILE__, 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures; | - | ||||||||||||||||||||||||
| 4606 | << "Normal gestures:" << normalGestures dead code: QMessageLogger(__FILE__, 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures; | - | ||||||||||||||||||||||||
| 4607 | << "Conflicting gestures:" << conflictedGestures; dead code: QMessageLogger(__FILE__, 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures; | - | ||||||||||||||||||||||||
| 4608 | - | |||||||||||||||||||||||||
| 4609 | - | |||||||||||||||||||||||||
| 4610 | - | |||||||||||||||||||||||||
| 4611 | if (!conflictedGestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4612 | for (int i = 0; i < cachedTargetItems.size()
| 0 | ||||||||||||||||||||||||
| 4613 | QPointer<QGraphicsObject> item = cachedTargetItems.at(i); | - | ||||||||||||||||||||||||
| 4614 | - | |||||||||||||||||||||||||
| 4615 | - | |||||||||||||||||||||||||
| 4616 | const QSet<QGesture *> gestures = conflictedGestures & cachedItemGestures.value(item.data()); | - | ||||||||||||||||||||||||
| 4617 | if (gestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4618 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4619 | - | |||||||||||||||||||||||||
| 4620 | if (0) QMessageLogger(__FILE__, 62656286, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" dead code: QMessageLogger(__FILE__, 6286, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures; | - | ||||||||||||||||||||||||
| 4621 | << "delivering override to" dead code: QMessageLogger(__FILE__, 6286, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures; | - | ||||||||||||||||||||||||
| 4622 | << item.data() << gestures; dead code: QMessageLogger(__FILE__, 6286, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures; | - | ||||||||||||||||||||||||
| 4623 | - | |||||||||||||||||||||||||
| 4624 | QGestureEvent ev(gestures.toList()); | - | ||||||||||||||||||||||||
| 4625 | ev.t = QEvent::GestureOverride; | - | ||||||||||||||||||||||||
| 4626 | ev.setWidget(event->widget()); | - | ||||||||||||||||||||||||
| 4627 | - | |||||||||||||||||||||||||
| 4628 | ev.ignore(); | - | ||||||||||||||||||||||||
| 4629 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0: gestures) | - | ||||||||||||||||||||||||
| 4630 | ev.setAccepted(g, false); never executed: ev.setAccepted(g, false); | 0 | ||||||||||||||||||||||||
| 4631 | sendEvent(item.data(), &ev); | - | ||||||||||||||||||||||||
| 4632 | - | |||||||||||||||||||||||||
| 4633 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0: gestures) { | - | ||||||||||||||||||||||||
| 4634 | if (ev.isAccepted()
| 0 | ||||||||||||||||||||||||
| 4635 | conflictedGestures.remove(g); | - | ||||||||||||||||||||||||
| 4636 | - | |||||||||||||||||||||||||
| 4637 | if (item
| 0 | ||||||||||||||||||||||||
| 4638 | gestureTargets.insert(g, item.data()); | - | ||||||||||||||||||||||||
| 4639 | QHash<QGraphicsObject *, QSet<QGesture *> >::iterator it, e; | - | ||||||||||||||||||||||||
| 4640 | it = cachedItemGestures.begin(); | - | ||||||||||||||||||||||||
| 4641 | e = cachedItemGestures.end(); | - | ||||||||||||||||||||||||
| 4642 | for(; it != e
| 0 | ||||||||||||||||||||||||
| 4643 | it.value().remove(g); never executed: it.value().remove(g); | 0 | ||||||||||||||||||||||||
| 4644 | cachedItemGestures[item.data()].insert(g); | - | ||||||||||||||||||||||||
| 4645 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4646 | if (0) QMessageLogger(__FILE__, 62916312, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" dead code: QMessageLogger(__FILE__, 6312, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data(); | - | ||||||||||||||||||||||||
| 4647 | << "override was accepted:" dead code: QMessageLogger(__FILE__, 6312, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data(); | - | ||||||||||||||||||||||||
| 4648 | << g << item.data(); dead code: QMessageLogger(__FILE__, 6312, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data(); | - | ||||||||||||||||||||||||
| 4649 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4650 | - | |||||||||||||||||||||||||
| 4651 | - | |||||||||||||||||||||||||
| 4652 | - | |||||||||||||||||||||||||
| 4653 | if (!gestureTargets.contains(g)
| 0 | ||||||||||||||||||||||||
| 4654 | gestureTargets.insert(g, item.data()); never executed: gestureTargets.insert(g, item.data()); | 0 | ||||||||||||||||||||||||
| 4655 | - | |||||||||||||||||||||||||
| 4656 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4657 | if (conflictedGestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4658 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4659 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4660 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4661 | - | |||||||||||||||||||||||||
| 4662 | - | |||||||||||||||||||||||||
| 4663 | if (!normalGestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4664 | for (int i = 0; i < cachedTargetItems.size()
| 0 | ||||||||||||||||||||||||
| 4665 | QGraphicsObject *item = cachedTargetItems.at(i); | - | ||||||||||||||||||||||||
| 4666 | - | |||||||||||||||||||||||||
| 4667 | - | |||||||||||||||||||||||||
| 4668 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(cachedItemGestures.value(item))>::type> _container_((const auto gestures = cachedItemGestures.value(item))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)); | - | ||||||||||||||||||||||||
| 4669 | for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0: gestures) { | - | ||||||||||||||||||||||||
| 4670 | if (!gestureTargets.contains(g)
| 0 | ||||||||||||||||||||||||
| 4671 | gestureTargets.insert(g, item); | - | ||||||||||||||||||||||||
| 4672 | normalGestures.remove(g); | - | ||||||||||||||||||||||||
| 4673 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4674 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4675 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4676 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4677 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4678 | - | |||||||||||||||||||||||||
| 4679 | - | |||||||||||||||||||||||||
| 4680 | - | |||||||||||||||||||||||||
| 4681 | QSet<QGesture *> undeliveredGestures; | - | ||||||||||||||||||||||||
| 4682 | QSet<QGesture *> parentPropagatedGestures; | - | ||||||||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(allGestures)>::type> _container_((allGestures)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||||||||
| 4683 | ++_container_.i, _container_.control ^= 1)for (QGesture *gesture = *_container_.i; _container_.control; _container_.control = 0: allGestures) { | - | ||||||||||||||||||||||||
| 4684 | if (QGraphicsObject *target = gestureTargets.value(gesture, 0)
| 0 | ||||||||||||||||||||||||
| 4685 | cachedItemGestures[target].insert(gesture); | - | ||||||||||||||||||||||||
| 4686 | cachedTargetItems.append(target); | - | ||||||||||||||||||||||||
| 4687 | undeliveredGestures.insert(gesture); | - | ||||||||||||||||||||||||
| 4688 | QGraphicsItemPrivate *d = target->QGraphicsItem::d_func(); | - | ||||||||||||||||||||||||
| 4689 | const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType()); | - | ||||||||||||||||||||||||
| 4690 | if (flags & Qt::IgnoredGesturesPropagateToParent
| 0 | ||||||||||||||||||||||||
| 4691 | parentPropagatedGestures.insert(gesture); never executed: parentPropagatedGestures.insert(gesture); | 0 | ||||||||||||||||||||||||
| 4692 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 4693 | if (0) QMessageLogger(__FILE__, 63376359, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" dead code: QMessageLogger(__FILE__, 6359, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "no target for" << gesture << "at" << gesture->hotSpot() << gesture->d_func()->sceneHotSpot; | - | ||||||||||||||||||||||||
| 4694 | << "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; | - | ||||||||||||||||||||||||
| 4695 | << 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; | - | ||||||||||||||||||||||||
| 4696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4697 | } | - | ||||||||||||||||||||||||
| 4698 | std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); | - | ||||||||||||||||||||||||
| 4699 | for (int i = 0; i < cachedTargetItems.size()
| 0 | ||||||||||||||||||||||||
| 4700 | QPointer<QGraphicsObject> receiver = cachedTargetItems.at(i); | - | ||||||||||||||||||||||||
| 4701 | QSet<QGesture *> gestures = | - | ||||||||||||||||||||||||
| 4702 | undeliveredGestures & cachedItemGestures.value(receiver.data()); | - | ||||||||||||||||||||||||
| 4703 | gestures -= cachedAlreadyDeliveredGestures.value(receiver.data()); | - | ||||||||||||||||||||||||
| 4704 | - | |||||||||||||||||||||||||
| 4705 | if (gestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4706 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4707 | - | |||||||||||||||||||||||||
| 4708 | cachedAlreadyDeliveredGestures[receiver.data()] += gestures; | - | ||||||||||||||||||||||||
| 4709 | const bool isPanel = receiver.data()->isPanel(); | - | ||||||||||||||||||||||||
| 4710 | - | |||||||||||||||||||||||||
| 4711 | if (0) QMessageLogger(__FILE__, 63556377, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" dead code: QMessageLogger(__FILE__, 6377, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures; | - | ||||||||||||||||||||||||
| 4712 | << "delivering to" dead code: QMessageLogger(__FILE__, 6377, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures; | - | ||||||||||||||||||||||||
| 4713 | << receiver.data() << gestures; dead code: QMessageLogger(__FILE__, 6377, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures; | - | ||||||||||||||||||||||||
| 4714 | QGestureEvent ev(gestures.toList()); | - | ||||||||||||||||||||||||
| 4715 | ev.setWidget(event->widget()); | - | ||||||||||||||||||||||||
| 4716 | sendEvent(receiver.data(), &ev); | - | ||||||||||||||||||||||||
| 4717 | QSet<QGesture *> ignoredGestures; | - | ||||||||||||||||||||||||
| 4718 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 4719 | if (!ev.isAccepted()
| 0 | ||||||||||||||||||||||||
| 4720 | - | |||||||||||||||||||||||||
| 4721 | - | |||||||||||||||||||||||||
| 4722 | - | |||||||||||||||||||||||||
| 4723 | - | |||||||||||||||||||||||||
| 4724 | - | |||||||||||||||||||||||||
| 4725 | if (receiver
| 0 | ||||||||||||||||||||||||
| 4726 | ignoredGestures.insert(g); never executed: ignoredGestures.insert(g); | 0 | ||||||||||||||||||||||||
| 4727 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 4728 | if (receiver
| 0 | ||||||||||||||||||||||||
| 4729 | - | |||||||||||||||||||||||||
| 4730 | - | |||||||||||||||||||||||||
| 4731 | gestureTargets[g] = receiver.data(); | - | ||||||||||||||||||||||||
| 4732 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4733 | undeliveredGestures.remove(g); | - | ||||||||||||||||||||||||
| 4734 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4735 | } | - | ||||||||||||||||||||||||
| 4736 | if (undeliveredGestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4737 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4738 | - | |||||||||||||||||||||||||
| 4739 | - | |||||||||||||||||||||||||
| 4740 | - | |||||||||||||||||||||||||
| 4741 | if (!ignoredGestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4742 | - | |||||||||||||||||||||||||
| 4743 | - | |||||||||||||||||||||||||
| 4744 | - | |||||||||||||||||||||||||
| 4745 | QSet<QGraphicsObject *> targetsSet = cachedTargetItems.toSet(); | - | ||||||||||||||||||||||||
| 4746 | - | |||||||||||||||||||||||||
| 4747 | if (receiver
| 0 | ||||||||||||||||||||||||
| 4748 | - | |||||||||||||||||||||||||
| 4749 | for (QSet<QGesture *>::iterator it = ignoredGestures.begin(); | - | ||||||||||||||||||||||||
| 4750 | it != ignoredGestures.end()
| 0 | ||||||||||||||||||||||||
| 4751 | if (parentPropagatedGestures.contains(*it)
| 0 | ||||||||||||||||||||||||
| 4752 | QGesture *gesture = *it; | - | ||||||||||||||||||||||||
| 4753 | const Qt::GestureType gestureType = gesture->gestureType(); | - | ||||||||||||||||||||||||
| 4754 | QGraphicsItem *item = receiver.data(); | - | ||||||||||||||||||||||||
| 4755 | while (item
| 0 | ||||||||||||||||||||||||
| 4756 | if (QGraphicsObject *obj = item->toGraphicsObject()
| 0 | ||||||||||||||||||||||||
| 4757 | if (item->d_func()->gestureContext.contains(gestureType)
| 0 | ||||||||||||||||||||||||
| 4758 | targetsSet.insert(obj); | - | ||||||||||||||||||||||||
| 4759 | cachedItemGestures[obj].insert(gesture); | - | ||||||||||||||||||||||||
| 4760 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4761 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4762 | if (item->isPanel()
| 0 | ||||||||||||||||||||||||
| 4763 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4764 | item = item->parentItem(); | - | ||||||||||||||||||||||||
| 4765 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4766 | - | |||||||||||||||||||||||||
| 4767 | it = ignoredGestures.erase(it); | - | ||||||||||||||||||||||||
| 4768 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4769 | } | - | ||||||||||||||||||||||||
| 4770 | ++it; | - | ||||||||||||||||||||||||
| 4771 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4772 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4773 | - | |||||||||||||||||||||||||
| 4774 | gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures, | - | ||||||||||||||||||||||||
| 4775 | &cachedItemGestures, &targetsSet, 0, 0); | - | ||||||||||||||||||||||||
| 4776 | - | |||||||||||||||||||||||||
| 4777 | cachedTargetItems = targetsSet.toList(); | - | ||||||||||||||||||||||||
| 4778 | std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); | - | ||||||||||||||||||||||||
| 4779 | if (0) QMessageLogger(__FILE__, 64236445, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" dead code: QMessageLogger(__FILE__, 6445, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "new targets:" << cachedTargetItems; | - | ||||||||||||||||||||||||
| 4780 | << "new targets:" << cachedTargetItems; dead code: QMessageLogger(__FILE__, 6445, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "new targets:" << cachedTargetItems; | - | ||||||||||||||||||||||||
| 4781 | i = -1; | - | ||||||||||||||||||||||||
| 4782 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4783 | } | - | ||||||||||||||||||||||||
| 4784 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4785 | - | |||||||||||||||||||||||||
| 4786 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(startedGestures)>::type> _container_((startedGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 4787 | if (g->gestureCancelPolicy() == QGesture::CancelAllInContext
| 0 | ||||||||||||||||||||||||
| 4788 | if (0) QMessageLogger(__FILE__, 64326454, __PRETTY_FUNCTION__).debug() << "lets try to cancel some"; dead code: QMessageLogger(__FILE__, 6454, __PRETTY_FUNCTION__).debug() << "lets try to cancel some"; | - | ||||||||||||||||||||||||
| 4789 | - | |||||||||||||||||||||||||
| 4790 | cancelGesturesForChildren(g); | - | ||||||||||||||||||||||||
| 4791 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4792 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4793 | - | |||||||||||||||||||||||||
| 4794 | - | |||||||||||||||||||||||||
| 4795 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(allGestures)>::type> _container_((allGestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0: allGestures) { | - | ||||||||||||||||||||||||
| 4796 | switch (g->state()) { | - | ||||||||||||||||||||||||
| 4797 | case never executed: Qt::GestureFinished:case Qt::GestureFinished:never executed: case Qt::GestureFinished: | 0 | ||||||||||||||||||||||||
| 4798 | case never executed: Qt::GestureCanceled:case Qt::GestureCanceled:never executed: case Qt::GestureCanceled: | 0 | ||||||||||||||||||||||||
| 4799 | gestureTargets.remove(g); | - | ||||||||||||||||||||||||
| 4800 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4801 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 4802 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4803 | } | - | ||||||||||||||||||||||||
| 4804 | } | - | ||||||||||||||||||||||||
| 4805 | - | |||||||||||||||||||||||||
| 4806 | cachedTargetItems.clear(); | - | ||||||||||||||||||||||||
| 4807 | cachedItemGestures.clear(); | - | ||||||||||||||||||||||||
| 4808 | cachedAlreadyDeliveredGestures.clear(); | - | ||||||||||||||||||||||||
| 4809 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4810 | - | |||||||||||||||||||||||||
| 4811 | void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) | - | ||||||||||||||||||||||||
| 4812 | { | - | ||||||||||||||||||||||||
| 4813 | ((!(original)) ? qt_assert("original",__FILE__,64576479) : qt_noop()); | - | ||||||||||||||||||||||||
| 4814 | QGraphicsItem *originalItem = gestureTargets.value(original); | - | ||||||||||||||||||||||||
| 4815 | if (originalItem == 0
| 0 | ||||||||||||||||||||||||
| 4816 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4817 | - | |||||||||||||||||||||||||
| 4818 | - | |||||||||||||||||||||||||
| 4819 | - | |||||||||||||||||||||||||
| 4820 | - | |||||||||||||||||||||||||
| 4821 | QSet<QGesture *> canceledGestures; | - | ||||||||||||||||||||||||
| 4822 | QHash<QGesture *, QGraphicsObject *>::Iterator iter = gestureTargets.begin(); | - | ||||||||||||||||||||||||
| 4823 | while (iter != gestureTargets.end()
| 0 | ||||||||||||||||||||||||
| 4824 | QGraphicsObject *item = iter.value(); | - | ||||||||||||||||||||||||
| 4825 | - | |||||||||||||||||||||||||
| 4826 | if (item != originalItem
| 0 | ||||||||||||||||||||||||
| 4827 | if (0) QMessageLogger(__FILE__, 64716493, __PRETTY_FUNCTION__).debug() << " found a gesture to cancel" << iter.key(); dead code: QMessageLogger(__FILE__, 6493, __PRETTY_FUNCTION__).debug() << " found a gesture to cancel" << iter.key(); | - | ||||||||||||||||||||||||
| 4828 | iter.key()->d_func()->state = Qt::GestureCanceled; | - | ||||||||||||||||||||||||
| 4829 | canceledGestures << iter.key(); | - | ||||||||||||||||||||||||
| 4830 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4831 | ++iter; | - | ||||||||||||||||||||||||
| 4832 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4833 | - | |||||||||||||||||||||||||
| 4834 | - | |||||||||||||||||||||||||
| 4835 | QSet<QGesture *> almostCanceledGestures = canceledGestures; | - | ||||||||||||||||||||||||
| 4836 | QSet<QGesture *>::Iterator setIter; | - | ||||||||||||||||||||||||
| 4837 | while (!almostCanceledGestures.isEmpty()
| 0 | ||||||||||||||||||||||||
| 4838 | QGraphicsObject *target = 0; | - | ||||||||||||||||||||||||
| 4839 | QSet<QGesture*> gestures; | - | ||||||||||||||||||||||||
| 4840 | setIter = almostCanceledGestures.begin(); | - | ||||||||||||||||||||||||
| 4841 | - | |||||||||||||||||||||||||
| 4842 | while (setIter != almostCanceledGestures.end()
| 0 | ||||||||||||||||||||||||
| 4843 | QGraphicsObject *item = gestureTargets.value(*setIter); | - | ||||||||||||||||||||||||
| 4844 | if (target == 0
| 0 | ||||||||||||||||||||||||
| 4845 | target = item; never executed: target = item; | 0 | ||||||||||||||||||||||||
| 4846 | if (target == item
| 0 | ||||||||||||||||||||||||
| 4847 | gestures << *setIter; | - | ||||||||||||||||||||||||
| 4848 | setIter = almostCanceledGestures.erase(setIter); | - | ||||||||||||||||||||||||
| 4849 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 4850 | ++setIter; | - | ||||||||||||||||||||||||
| 4851 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4852 | } | - | ||||||||||||||||||||||||
| 4853 | ((!(target)) ? qt_assert("target",__FILE__,64976519) : qt_noop()); | - | ||||||||||||||||||||||||
| 4854 | - | |||||||||||||||||||||||||
| 4855 | const QList<QGesture *> list = gestures.toList(); | - | ||||||||||||||||||||||||
| 4856 | QGestureEvent ev(list); | - | ||||||||||||||||||||||||
| 4857 | sendEvent(target, &ev); | - | ||||||||||||||||||||||||
| 4858 | - | |||||||||||||||||||||||||
| 4859 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(list)>::type> _container_((list)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_if (!ev
| 0 | ||||||||||||||||||||||||
| 4860 | for (QGesture *g = *_container_.i; _container_.control; _container_.control = 0: list) { | - | ||||||||||||||||||||||||
| 4861 | - | |||||||||||||||||||||||||
| 4862 | if (ev.isAccepted() ||ev.isAccepted(g)
| 0 | ||||||||||||||||||||||||
| 4863 | gestures.remove(g); | 0 | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(gestures)>::type> _container_((gestures)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGesture *g = *_container_.i; _container_.controlcontinue never executed: ;continue;never executed: continue; | ||||||||||||||||||||||||||
| 4864 | - | |||||||||||||||||||||||||
| 4865 | _container_.control = 0) {if (!g->hasHotSpot()
| 0 | ||||||||||||||||||||||||
| 4866 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4867 | - | |||||||||||||||||||||||||
| 4868 | QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0); | - | ||||||||||||||||||||||||
| 4869 | for (int j = 0; j < items.size()
| 0 | ||||||||||||||||||||||||
| 4870 | QGraphicsObject *item = items.at(j)->toGraphicsObject(); | - | ||||||||||||||||||||||||
| 4871 | if (!item
| 0 | ||||||||||||||||||||||||
| 4872 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 4873 | QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); | - | ||||||||||||||||||||||||
| 4874 | if (d->gestureContext.contains(g->gestureType())
| 0 | ||||||||||||||||||||||||
| 4875 | QList<QGesture *> list; | - | ||||||||||||||||||||||||
| 4876 | list << g; | - | ||||||||||||||||||||||||
| 4877 | QGestureEvent ev(list); | - | ||||||||||||||||||||||||
| 4878 | sendEvent(item, &ev); | - | ||||||||||||||||||||||||
| 4879 | if (ev.isAccepted()
| 0 | ||||||||||||||||||||||||
| 4880 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4881 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4882 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4883 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4884 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4885 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4886 | - | |||||||||||||||||||||||||
| 4887 | QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager; | - | ||||||||||||||||||||||||
| 4888 | ((!(gestureManager)) ? qt_assert("gestureManager",__FILE__,65316554) : qt_noop()); | - | ||||||||||||||||||||||||
| 4889 | for (setIter = canceledGestures.begin(); setIter != canceledGestures.end()
| 0 | ||||||||||||||||||||||||
| 4890 | gestureManager->recycle(*setIter); | - | ||||||||||||||||||||||||
| 4891 | gestureTargets.remove(*setIter); | - | ||||||||||||||||||||||||
| 4892 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4893 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4894 | - | |||||||||||||||||||||||||
| 4895 | void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture) | - | ||||||||||||||||||||||||
| 4896 | { | - | ||||||||||||||||||||||||
| 4897 | (void)QGestureManager::instance(); | - | ||||||||||||||||||||||||
| 4898 | if (!grabbedGestures[gesture]++) { | - | ||||||||||||||||||||||||
| 4899 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(views)>::type> _container_((views)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsView *view = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
| 4900 | view->viewport()->grabGesture(gesture); | - | ||||||||||||||||||||||||
| 4901 | } | - | ||||||||||||||||||||||||
| 4902 | } | - | ||||||||||||||||||||||||
| 4903 | - | |||||||||||||||||||||||||
| 4904 | void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType gesture) | - | ||||||||||||||||||||||||
| 4905 | { | - | ||||||||||||||||||||||||
| 4906 | - | |||||||||||||||||||||||||
| 4907 | ((!(item->d_ptr->isObject)) ? qt_assert("item->d_ptr->isObject",__FILE__,65506573) : qt_noop()); | - | ||||||||||||||||||||||||
| 4908 | QGraphicsObject *obj = static_cast<QGraphicsObject *>(item); | - | ||||||||||||||||||||||||
| 4909 | QGestureManager::instance()->cleanupCachedGestures(obj, gesture); | - | ||||||||||||||||||||||||
| 4910 | if (!--grabbedGestures[gesture]) { | - | ||||||||||||||||||||||||
| 4911 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(views)>::type> _container_((views)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QGraphicsView *view = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||||||||
| 4912 | view->viewport()->ungrabGesture(gesture); | - | ||||||||||||||||||||||||
| 4913 | } | - | ||||||||||||||||||||||||
| 4914 | } | - | ||||||||||||||||||||||||
| 4915 | - | |||||||||||||||||||||||||
| 4916 | - | |||||||||||||||||||||||||
| 4917 | - | |||||||||||||||||||||||||
| 4918 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |