Set the wheelEvent Like libreCad or Autocad: Onclick select visu mode and drag schema.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2106 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
cfdev
2013-04-13 12:26:42 +00:00
parent 1a27dd8fb3
commit ff916f1320
2 changed files with 38 additions and 21 deletions

View File

@@ -410,10 +410,12 @@ void DiagramView::pasteHere() {
}
/**
Manage the events click mouse :
Manage the press events click mouse :
* click to add an independent text field
*/
void DiagramView::mousePressEvent(QMouseEvent *e) {
// Save the button in flag
FlagMouseButtons_ = e->buttons();
if (fresh_focus_in_) {
switchToVisualisationModeIfNeeded(e);
fresh_focus_in_ = false;
@@ -424,35 +426,48 @@ void DiagramView::mousePressEvent(QMouseEvent *e) {
is_adding_text = false;
}
}
// Select visualisation
if (e->buttons() == Qt::MidButton){
if (!is_moving_view_) {
setVisualisationMode();
is_moving_view_ = true;
// And Simulate the left click
QGraphicsView::mousePressEvent( new QMouseEvent(QEvent::MouseButtonPress, e->pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier) );
}
}
QGraphicsView::mousePressEvent(e);
}
/**
Manage wheel event of mouse
@param e QWheelEvent
Manage the release events click mouse :
*/
void DiagramView::wheelEvent(QWheelEvent *e) {
//Zoom and scrolling
if (e->buttons() != Qt::MidButton) {
if (!(e -> modifiers() & Qt::ControlModifier)) {
if (e -> delta() > 0) zoomIn();
else zoomOut();
}
else {
QAbstractScrollArea::wheelEvent(e);
}
}
// Or select visualisation or selection mode
else{
if (!is_moving_view_) {
setVisualisationMode();
is_moving_view_ = true;
}
else{
void DiagramView::mouseReleaseEvent(QMouseEvent *e) {
// Selection mode
if (FlagMouseButtons_ == Qt::MidButton){
if (is_moving_view_) {
setSelectionMode();
is_moving_view_ = false;
}
}
QGraphicsView::mousePressEvent(e);
}
/**
Manage wheel event of mouse for Zoom and scrolling
@param e QWheelEvent
*/
void DiagramView::wheelEvent(QWheelEvent *e) {
if (!(e -> modifiers() & Qt::ControlModifier)) {
if (e -> delta() > 0) {
zoomIn();
}
else {
zoomOut();
}
}
else {
QAbstractScrollArea::wheelEvent(e);
}
}
/**