QVariant MInverseMouseArea::itemChange(GraphicsItemChange change, const QVariant &value) { switch (change) { case QGraphicsItem::ItemSceneChange: { QGraphicsScene *oldScene = scene(); if (oldScene) oldScene->removeEventFilter(this); m_pressed = false; if (value.canConvert<QGraphicsScene *>()) { QGraphicsScene *newScene = value.value<QGraphicsScene *>(); if (newScene) newScene->installEventFilter(this); } break; } case QGraphicsItem::ItemVisibleHasChanged: { if (!isVisible()) m_pressed = false; break; } default: break; } return QDeclarativeItem::itemChange(change, value); }
void ArrangementDemoWindow::removeCallback( unsigned int tabIndex ) { if (tabIndex == static_cast<unsigned int>(-1)) return; ArrangementDemoTabBase* activeTab = this->tabs[ tabIndex ]; QGraphicsScene* activeScene = activeTab->getScene( ); QGraphicsView* activeView = activeTab->getView( ); #if 0 QAction* activeMode = this->activeModes[ tabIndex ]; #endif activeScene->removeEventFilter( activeTab->getCurveInputCallback( ) ); activeView->setDragMode( QGraphicsView::NoDrag ); activeScene->removeEventFilter( activeTab->getDeleteCurveCallback( ) ); activeScene->removeEventFilter( activeTab->getPointLocationCallback( ) ); activeScene->removeEventFilter( activeTab->getVerticalRayShootCallback( ) ); activeScene->removeEventFilter( activeTab->getMergeEdgeCallback( ) ); activeScene->removeEventFilter( activeTab->getSplitEdgeCallback( ) ); activeScene->removeEventFilter( activeTab->getVerticalRayShootCallback( ) ); activeScene->removeEventFilter( activeTab->getFillFaceCallback( ) ); // unhook the old active mode #if 0 if ( activeMode == this->ui->actionInsert ) { activeScene->removeEventFilter( activeTab->getCurveInputCallback( ) ); } else if ( activeMode == this->ui->actionDrag ) { activeView->setDragMode( QGraphicsView::NoDrag ); } else if ( activeMode == this->ui->actionDelete ) { activeScene->removeEventFilter( activeTab->getDeleteCurveCallback( ) ); } else if ( activeMode == this->ui->actionPointLocation ) { activeScene->removeEventFilter( activeTab->getPointLocationCallback( ) ); } else if ( activeMode == this->ui->actionRayShootingUp ) { activeScene->removeEventFilter( activeTab->getVerticalRayShootCallback( ) ); } else if ( activeMode == this->ui->actionRayShootingDown ) { activeScene->removeEventFilter( activeTab->getVerticalRayShootCallback( ) ); } else if ( activeMode == this->ui->actionMerge ) { activeScene->removeEventFilter( activeTab->getMergeEdgeCallback( ) ); } else if ( activeMode == this->ui->actionSplit ) { activeScene->removeEventFilter( activeTab->getSplitEdgeCallback( ) ); } #endif }