[qet] [2091] Update wheel mouse event and add the possibility to change mode ( selection, visu) with the wheel click.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2091
Author:   cfdev
Date:     2013-04-08 16:39:50 +0200 (Mon, 08 Apr 2013)
Log Message:
-----------
Update wheel mouse event and add the possibility to change mode (selection, visu) with the wheel click.

Modified Paths:
--------------
    trunk/sources/diagramview.cpp

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2013-04-06 18:54:32 UTC (rev 2090)
+++ trunk/sources/diagramview.cpp	2013-04-08 14:39:50 UTC (rev 2091)
@@ -419,16 +419,6 @@
 		switchToVisualisationModeIfNeeded(e);
 		fresh_focus_in_ = false;
 	}
-	if (isInteractive() && !scene -> isReadOnly()) {
-		if (e -> buttons() == Qt::MidButton) {
-			paste(mapToScene(e -> pos()), QClipboard::Selection);
-		} else {
-			if (is_adding_text && e -> buttons() == Qt::LeftButton) {
-				addDiagramTextAtPos(mapToScene(e -> pos()));
-				is_adding_text = false;
-			}
-		}
-	}
 	QGraphicsView::mousePressEvent(e);
 }
 
@@ -437,11 +427,27 @@
 	@param e QWheelEvent
 */
 void DiagramView::wheelEvent(QWheelEvent *e) {
-	if (e -> delta() > 0) {
-		zoomIn();
-	} else {
-		zoomOut();
+	//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{
+			setSelectionMode();
+			is_moving_view_ = false;
+		}
+	}
 }
 
 /**


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/