[qet] [3849] Minor change about how drag view work ( diagram editor and element editor)

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


Revision: 3849
Author:   blacksun
Date:     2015-03-24 23:21:58 +0100 (Tue, 24 Mar 2015)
Log Message:
-----------
Minor change about how drag view work (diagram editor and element editor)

Modified Paths:
--------------
    trunk/sources/diagramview.cpp
    trunk/sources/diagramview.h
    trunk/sources/editor/elementview.cpp
    trunk/sources/editor/elementview.h

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2015-03-23 18:43:53 UTC (rev 3848)
+++ trunk/sources/diagramview.cpp	2015-03-24 22:21:58 UTC (rev 3849)
@@ -470,7 +470,7 @@
 }
 
 /**
-	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 @@
 		}
 	}
 
-	//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 @@
 			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);

Modified: trunk/sources/diagramview.h
===================================================================
--- trunk/sources/diagramview.h	2015-03-23 18:43:53 UTC (rev 3848)
+++ trunk/sources/diagramview.h	2015-03-24 22:21:58 UTC (rev 3849)
@@ -50,7 +50,6 @@
 		QAction          *find_element_;
 		QPoint            paste_here_pos;
 		QPoint            next_position_;
-		QPointF           center_view_;
 		QPointF           rubber_band_origin;
 		bool              fresh_focus_in_;    ///< Indicate the focus was freshly gained
 		ElementsLocation  next_location_;

Modified: trunk/sources/editor/elementview.cpp
===================================================================
--- trunk/sources/editor/elementview.cpp	2015-03-23 18:43:53 UTC (rev 3848)
+++ trunk/sources/editor/elementview.cpp	2015-03-24 22:21:58 UTC (rev 3849)
@@ -360,14 +360,13 @@
 	@param e QMouseEvent decrivant l'evenement souris
 */
 void ElementView::mousePressEvent(QMouseEvent *e) {
-	// Select visualisation or selection mode
-	if (e -> buttons() == Qt::MidButton) {
-		setCursor(Qt::ClosedHandCursor);
-		reference_view_ = mapToScene(e -> pos());
-		center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
-		return;
+	if (e->buttons() == Qt::MidButton)
+	{
+		setCursor( (Qt::ClosedHandCursor));
+		reference_view_ = e->pos();
 	}
-	QGraphicsView::mousePressEvent(e);
+	else
+		QGraphicsView::mousePressEvent(e);
 }
 
 /**
@@ -375,14 +374,17 @@
  * Manage the event move mouse
  */
 void ElementView::mouseMoveEvent(QMouseEvent *e) {
-	if ((e -> buttons() & Qt::MidButton) == Qt::MidButton) {
-		QPointF move = reference_view_ - mapToScene(e -> pos());
-		this -> centerOn(center_view_ + move);
-		center_view_ = mapToScene(this -> viewport() -> rect()).boundingRect().center();
-		adjustSceneRect();
-		return;
+	if (e->buttons() == Qt::MidButton)
+	{
+		QScrollBar *h = horizontalScrollBar();
+		QScrollBar *v = verticalScrollBar();
+		QPointF pos = reference_view_ - e -> pos();
+		reference_view_ = e -> pos();
+		h -> setValue(h -> value() + pos.x());
+		v -> setValue(v -> value() + pos.y());
 	}
-	QGraphicsView::mouseMoveEvent(e);
+	else
+		QGraphicsView::mouseMoveEvent(e);
 }
 
 /**

Modified: trunk/sources/editor/elementview.h
===================================================================
--- trunk/sources/editor/elementview.h	2015-03-23 18:43:53 UTC (rev 3848)
+++ trunk/sources/editor/elementview.h	2015-03-24 22:21:58 UTC (rev 3849)
@@ -89,8 +89,6 @@
 	int offset_paste_count_;
 	QPointF start_top_left_corner_;
 	QPointF reference_view_;
-	QPointF center_view_;
 	bool gestures() const;
-	bool is_moving_view_;               ///< Indicate whether the visualisation mode has been enabled due to mouse/keyboard interactions
 };
 #endif


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