46 #include <QGraphicsView>
47 #include <QGraphicsSceneMouseEvent>
48 #include <QGestureEvent>
56 using namespace DISPLIB;
64 : QGraphicsScene(parent)
69 m_qvView->grabGesture(Qt::PanGesture);
70 m_qvView->grabGesture(Qt::PinchGesture);
79 m_qvView->setTransformationAnchor(QGraphicsView::AnchorViewCenter);
82 double scaleFactor = 1.15;
83 if(
event->delta() > 0) {
85 m_qvView->scale(scaleFactor, scaleFactor);
88 m_qvView->scale(1.0 / scaleFactor, 1.0 / scaleFactor);
96 if(mouseEvent->button() == Qt::LeftButton)
97 m_qvView->fitInView(this->itemsBoundingRect(), Qt::KeepAspectRatio);
99 QGraphicsScene::mouseDoubleClickEvent(mouseEvent);
106 switch(mouseEvent->button()) {
108 m_qvView->setDragMode(QGraphicsView::RubberBandDrag);
116 case Qt::RightButton:
118 m_qvView->setDragMode(QGraphicsView::NoDrag);
125 QGraphicsScene::mousePressEvent(mouseEvent);
138 m_qvView->verticalScrollBar()->setValue(
m_qvView->verticalScrollBar()->value() - diffY);
139 m_qvView->horizontalScrollBar()->setValue(
m_qvView->horizontalScrollBar()->value() - diffX);
142 QGraphicsScene::mouseMoveEvent(mouseEvent);
180 QGraphicsScene::mouseReleaseEvent(mouseEvent);
190 QGraphicsScene::keyPressEvent(keyEvent);
200 QGraphicsScene::keyReleaseEvent(keyEvent);
207 if (
event->type() == QEvent::Gesture) {
208 QGestureEvent* gestureEventCast =
static_cast<QGestureEvent*
>(
event);
215 return gestureEvent(
static_cast<QGestureEvent*
>(gestureEventCast));
218 return QGraphicsScene::event(
event);
226 if (QGesture *pan =
event->gesture(Qt::PanGesture))
230 if (QGesture *pinch =
event->gesture(Qt::PinchGesture))
240 QPointF delta = gesture->delta();
242 m_qvView->verticalScrollBar()->setValue(
m_qvView->verticalScrollBar()->value() + delta.y());
243 m_qvView->horizontalScrollBar()->setValue(
m_qvView->horizontalScrollBar()->value() + delta.x());
250 m_qvView->setTransformationAnchor(QGraphicsView::NoAnchor);
251 m_qvView->scale(gesture->scaleFactor(), gesture->scaleFactor());
258 if (
object ==
m_qvView &&
event->type() == QEvent::Gesture) {
259 QGestureEvent* gestureEventCast =
static_cast<QGestureEvent*
>(
event);
261 return gestureEvent(
static_cast<QGestureEvent*
>(gestureEventCast));