/* * This is reimplemented because of a bug in Qt 4.3 QGraphicScene in the * way it handles context menu events. The docs say that if an item ignores * this event that it'll be passed down to the next item underneath. However, * this does not happen in the default implementation. */ void Scene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QList<QGraphicsItem*> list = items(event->scenePos()); foreach (QGraphicsItem *item, list) { ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item); if (!viewItem) continue; if (viewItem->acceptsContextMenuEvents()) { event->setPos(viewItem->mapFromScene(event->scenePos())); if (viewItem->sceneEvent(event)) return; } }
/* * This is reimplemented because of a bug in Qt 4.3 QGraphicScene in the * way it handles context menu events. The docs say that if an item ignores * this event that it'll be passed down to the next item underneath. However, * this does not happen in the default implementation. */ void Scene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QList<QGraphicsItem*> list = items(event->scenePos()); if (list.isEmpty()) { if (View *view = qobject_cast<View*>(parent())) { view->viewContextMenuEvent(); } } else { foreach (QGraphicsItem *item, list) { ViewItem *viewItem = dynamic_cast<ViewItem*>(item); if (!viewItem) continue; if (viewItem->acceptsContextMenuEvents()) { event->setPos(viewItem->mapFromScene(event->scenePos())); if (viewItem->doSceneEvent(event)) return; } } }