SANKORE-139 refactoring mouse scroll processing for View and GraphicsItems

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent 5b35036555
commit b5bda89005
  1. 29
      src/board/UBBoardView.cpp
  2. 4
      src/domain/UBGraphicsItemDelegate.cpp
  3. 3
      src/domain/UBGraphicsProxyWidget.cpp

@ -634,18 +634,38 @@ UBBoardView::mouseDoubleClickEvent (QMouseEvent *event)
} }
void void
UBBoardView::wheelEvent (QWheelEvent *event) UBBoardView::wheelEvent (QWheelEvent *wheelEvent)
{ {
if (isInteractive () && event->orientation () == Qt::Vertical) if (isInteractive () && wheelEvent->orientation () == Qt::Vertical)
{ {
// Too many wheelEvent are sent, how should we handle them to "smoothly" zoom ? // Too many wheelEvent are sent, how should we handle them to "smoothly" zoom ?
// something like zoom( pow(zoomFactor, event->delta() / 120) ) // something like zoom( pow(zoomFactor, event->delta() / 120) )
// use DateTime man, store last event time, and if if less than 300ms than this is one big scroll // use DateTime man, store last event time, and if if less than 300ms than this is one big scroll
// and move scroll with one const speed. // and move scroll with one const speed.
// so, you no will related with scroll event count // so, you no will related with scroll event count
} }
// event->accept ();
QGraphicsView::wheelEvent(event); QList<QGraphicsItem *> selItemsList = scene()->selectedItems();
// if NO have selected items, than no need process mouse wheel. just exist
if( selItemsList.count() > 0 )
{
// only one selected item possible, so we will work with first item only
QGraphicsItem * selItem = selItemsList[0];
// get items list under mouse cursor
QPointF scenePos = mapToScene(wheelEvent->pos());
QList<QGraphicsItem *> itemsList = scene()->items(scenePos);
QBool isSlectedAndMouseHower = itemsList.contains(selItem);
if(isSlectedAndMouseHower)
{
wheelEvent->accept();
QGraphicsView::wheelEvent(wheelEvent);
}
}
} }
void void
@ -895,4 +915,3 @@ UBBoardView::setToolCursor (int tool)
} }
} }

@ -195,12 +195,12 @@ bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)
{ {
if( mDelegated->isSelected() ) if( mDelegated->isSelected() )
{ {
event->accept(); // event->accept();
return true; return true;
} }
else else
{ {
event->ignore(); // event->ignore();
return false; return false;
} }
} }

@ -105,7 +105,10 @@ void UBGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
if( mDelegate->weelEvent(event) ) if( mDelegate->weelEvent(event) )
{
QGraphicsProxyWidget::wheelEvent(event); QGraphicsProxyWidget::wheelEvent(event);
event->accept();
}
} }

Loading…
Cancel
Save