Commit f4812666 authored by Ralf Habacker's avatar Ralf Habacker

Pan diagram window with middle mouse button.

CCBUG:107173
parent c2f0e8d3
......@@ -223,6 +223,34 @@ void UMLView::closeEvent(QCloseEvent* ce)
QWidget::closeEvent(ce);
}
/**
* Override standard method.
*/
void UMLView::mousePressEvent(QMouseEvent* event)
{
if (event->button() == Qt::MidButton) {
setDragMode(QGraphicsView::ScrollHandDrag);
setInteractive(false);
QMouseEvent fake(event->type(), event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers());
QGraphicsView::mousePressEvent(&fake);
} else
QGraphicsView::mousePressEvent(event);
}
/**
* Override standard method.
*/
void UMLView::mouseReleaseEvent(QMouseEvent* event)
{
if (event->button() == Qt::MidButton) {
QMouseEvent fake(event->type(), event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers());
QGraphicsView::mouseReleaseEvent(&fake);
setInteractive(true);
setDragMode(QGraphicsView::NoDrag);
} else
QGraphicsView::mouseReleaseEvent(event);
}
/**
* Sets the current centerpoint. Also updates the scene's center point.
* Unlike centerOn, which has no way of getting the floating point center
......
......@@ -55,12 +55,13 @@ protected:
virtual void showEvent(QShowEvent *se);
virtual void hideEvent(QHideEvent *he);
virtual void closeEvent(QCloseEvent* ce);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
void setCenter(const QPointF& centerPoint);
QPointF center();
QPointF m_currentCenterPoint; ///< holds the current centerpoint for the view, used for panning and zooming
QPoint m_lastPanPoint; ///< from panning the view
int m_nZoom; ///< zoom level in percent, default 100
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment