Minor change about how drag view work (diagram editor and element editor)

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3849 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-03-24 22:21:58 +00:00
parent 9072d3de04
commit 2f9fd79371
4 changed files with 31 additions and 27 deletions

View File

@@ -470,7 +470,7 @@ void DiagramView::pasteHere() {
}
/**
Manage the events press click mouse :
Manage the events press click :
* click to add an independent text field
*/
void DiagramView::mousePressEvent(QMouseEvent *e) {
@@ -490,11 +490,11 @@ void DiagramView::mousePressEvent(QMouseEvent *e) {
}
}
//Start drag view when hold the middle button
if (e -> button() == Qt::MidButton) {
rubber_band_origin = mapToScene(e -> pos());
//Start drag view when hold the middle button
if (e->button() == Qt::MidButton)
{
rubber_band_origin = e->pos();
setCursor(Qt::ClosedHandCursor);
center_view_ = mapToScene(this -> viewport() -> rect().center());
}
else QGraphicsView::mousePressEvent(e);
@@ -515,11 +515,16 @@ void DiagramView::mouseMoveEvent(QMouseEvent *e) {
return;
}
}
//Drag the view
if (e -> buttons() == Qt::MidButton) {
QPointF move = rubber_band_origin - mapToScene(e -> pos());
this -> centerOn(center_view_ + move);
center_view_ = mapToScene( this -> viewport() -> rect().center() );
//Drag the view
if (e->buttons() == Qt::MidButton)
{
QScrollBar *h = horizontalScrollBar();
QScrollBar *v = verticalScrollBar();
QPointF pos = rubber_band_origin - e -> pos();
rubber_band_origin = e -> pos();
h -> setValue(h -> value() + pos.x());
v -> setValue(v -> value() + pos.y());
}
else QGraphicsView::mouseMoveEvent(e);